Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose Scope#items #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,21 @@ use crate::r#impl::Impl;
use crate::r#struct::Struct;
use crate::r#trait::Trait;

/// The types of items that can be defined.
#[derive(Debug, Clone)]
pub enum Item {
/// Module
Module(Module),
/// Struct
Struct(Struct),
/// Function
Function(Function),
/// Trait
Trait(Trait),
/// Enum
Enum(Enum),
/// Impl
Impl(Impl),
/// Raw
Raw(String),
}
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pub use field::*;
pub use formatter::*;
pub use function::*;
pub use import::*;
pub use item::*;
pub use module::*;
pub use scope::*;
pub use variant::*;
Expand Down
5 changes: 5 additions & 0 deletions src/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ impl Scope {
ret
}

/// Return the items in the scope.
pub fn items(&self) -> &Vec<Item> {
&self.items
}

/// Formats the scope using the given formatter.
pub fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
self.fmt_imports(fmt)?;
Expand Down