pub struct ModuleItem<'a> { /* private fields */ }
Implementations§
Source§impl<'a> ModuleItem<'a>
impl<'a> ModuleItem<'a>
Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Examples found in repository?
examples/items.rs (line 25)
1fn main() {
2 use crate_inspector::CrateBuilder;
3
4 let builder = CrateBuilder::default()
5 .toolchain("nightly")
6 .manifest_path("Cargo.toml");
7 let krate = builder.build().unwrap();
8
9 for item in krate.items() {
10 println!("item: {:?}", item.name);
11 }
12 for strc in krate.structs() {
13 println!("struct: {}", strc.name());
14 println!("#impls: {}", strc.impls().count());
15 }
16 for enm in krate.enums() {
17 println!("enum: {}", enm.name());
18 println!("variants: {:?}", enm.variants().collect::<Vec<_>>());
19 println!(
20 "#methods: {}",
21 enm.impls().fold(0, |acc, i| acc + i.functions().count())
22 );
23 }
24 for sub in krate.sub_modules() {
25 println!("submodule: {}", sub.name());
26 }
27 if let Some(item) = krate.get_item("format") {
28 println!("item: {:?}", item.id);
29 }
30}
pub fn item_ids(&self) -> impl Iterator<Item = &Id>
pub fn items(&self) -> impl Iterator<Item = &Item>
pub fn parent(&self) -> Option<ModuleItem<'a>>
Source§impl<'a> ModuleItem<'a>
impl<'a> ModuleItem<'a>
pub fn constants(&self) -> impl Iterator<Item = ConstantItem<'_>>
pub fn functions(&self) -> impl Iterator<Item = FunctionItem<'_>>
pub fn structs(&self) -> impl Iterator<Item = StructItem<'_>>
pub fn enums(&self) -> impl Iterator<Item = EnumItem<'_>>
pub fn traits(&self) -> impl Iterator<Item = TraitItem<'_>>
pub fn type_aliases(&self) -> impl Iterator<Item = TypeAliasItem<'_>>
pub fn trait_aliases(&self) -> impl Iterator<Item = TraitAliasItem<'_>>
pub fn unions(&self) -> impl Iterator<Item = UnionItem<'_>>
pub fn modules(&self) -> impl Iterator<Item = ModuleItem<'_>>
pub fn impls(&self) -> impl Iterator<Item = ImplItem<'_>>
pub fn uses(&self) -> impl Iterator<Item = UseItem<'_>>
Sourcepub fn get_constant(&self, name: &str) -> Option<ConstantItem<'_>>
pub fn get_constant(&self, name: &str) -> Option<ConstantItem<'_>>
Get a constant by its name.
Sourcepub fn get_function(&self, name: &str) -> Option<FunctionItem<'_>>
pub fn get_function(&self, name: &str) -> Option<FunctionItem<'_>>
Get a function by its name.
Sourcepub fn get_struct(&self, name: &str) -> Option<StructItem<'_>>
pub fn get_struct(&self, name: &str) -> Option<StructItem<'_>>
Get a struct by its name.
Sourcepub fn get_type_alias(&self, name: &str) -> Option<TypeAliasItem<'_>>
pub fn get_type_alias(&self, name: &str) -> Option<TypeAliasItem<'_>>
Get a type alias by its name.
Sourcepub fn get_trait_alias(&self, name: &str) -> Option<TraitAliasItem<'_>>
pub fn get_trait_alias(&self, name: &str) -> Option<TraitAliasItem<'_>>
Get a trait alias by its name.
Sourcepub fn get_module(&self, name: &str) -> Option<ModuleItem<'_>>
pub fn get_module(&self, name: &str) -> Option<ModuleItem<'_>>
Get a module by its name.
Trait Implementations§
Source§impl<'a> Clone for ModuleItem<'a>
impl<'a> Clone for ModuleItem<'a>
Source§fn clone(&self) -> ModuleItem<'a>
fn clone(&self) -> ModuleItem<'a>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<'a> CrateItem<'a> for ModuleItem<'a>
impl<'a> CrateItem<'a> for ModuleItem<'a>
type Inner = Module
fn downcast(inner: &'a ItemEnum) -> Option<&'a Self::Inner>
fn new(krate: &'a Crate, item: &'a Item, module: &'a Self::Inner) -> Self
fn item(&self) -> &'a Item
fn inner(&self) -> &'a Self::Inner
fn krate(&self) -> &'a Crate
fn is_public(&self) -> bool
fn is_crate_item(&self) -> bool
fn is_root_item(&self) -> bool
fn is_external_item(&self) -> bool
fn id(&'a self) -> &'a Id
fn module(&self) -> Option<ModuleItem<'a>>
Source§impl<'a> Debug for ModuleItem<'a>
impl<'a> Debug for ModuleItem<'a>
Source§impl<'a> PartialEq for ModuleItem<'a>
impl<'a> PartialEq for ModuleItem<'a>
impl<'a> Copy for ModuleItem<'a>
impl<'a> Eq for ModuleItem<'a>
impl<'a> StructuralPartialEq for ModuleItem<'a>
Auto Trait Implementations§
impl<'a> Freeze for ModuleItem<'a>
impl<'a> RefUnwindSafe for ModuleItem<'a>
impl<'a> Send for ModuleItem<'a>
impl<'a> Sync for ModuleItem<'a>
impl<'a> Unpin for ModuleItem<'a>
impl<'a> UnwindSafe for ModuleItem<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.