pub struct Module { /* private fields */ }
Implementations
NB: Module is !HasSource, because it has two source nodes at the same time: definition and declaration.
Returns a node which defines this module. That is, a file or a mod foo {}
with items.
Returns a node which declares this module, either a mod foo;
or a mod foo {}
.
None
for the crate root.
Name of this module.
Topmost parent of this module. Every module has a crate_root
, but some
might be missing krate
. This can happen if a module’s file is not included
in the module tree of any target in Cargo.toml
.
Iterates over all child modules.
Finds a parent module.
Returns a ModuleScope
: a set of items, visible in this module.
pub fn find_use_path(
self,
db: &dyn DefDatabase,
item: impl Into<ItemInNs>
) -> Option<ModPath>
pub fn find_use_path(
self,
db: &dyn DefDatabase,
item: impl Into<ItemInNs>
) -> Option<ModPath>
Finds a path that can be used to refer to the given item from within this module, if possible.
pub fn find_use_path_prefixed(
self,
db: &dyn DefDatabase,
item: impl Into<ItemInNs>,
prefix_kind: PrefixKind
) -> Option<ModPath>
pub fn find_use_path_prefixed(
self,
db: &dyn DefDatabase,
item: impl Into<ItemInNs>,
prefix_kind: PrefixKind
) -> Option<ModPath>
Finds a path that can be used to refer to the given item from within this module, if possible. This is used for returning import paths for use-statements.
Trait Implementations
fn resolve_doc_path(
self,
db: &dyn HirDatabase,
link: &str,
ns: Option<Namespace>
) -> Option<Either<ModuleDef, MacroDef>>
fn into_displayable(
&'a self,
db: &'a (dyn HirDatabase + 'a),
max_size: Option<usize>,
omit_verbose_types: bool,
display_target: DisplayTarget
) -> HirDisplayWrapper<'a, Self>
fn into_displayable(
&'a self,
db: &'a (dyn HirDatabase + 'a),
max_size: Option<usize>,
omit_verbose_types: bool,
display_target: DisplayTarget
) -> HirDisplayWrapper<'a, Self>
Returns a Display
able type that is human-readable.
Returns a Display
able type that is human-readable.
Use this for showing types to the user (e.g. diagnostics) Read more
fn display_truncated(
&'a self,
db: &'a (dyn HirDatabase + 'a),
max_size: Option<usize>
) -> HirDisplayWrapper<'a, Self>
fn display_truncated(
&'a self,
db: &'a (dyn HirDatabase + 'a),
max_size: Option<usize>
) -> HirDisplayWrapper<'a, Self>
Returns a Display
able type that is human-readable and tries to be succinct.
Use this for showing types to the user where space is constrained (e.g. doc popups) Read more
fn display_source_code(
&'a self,
db: &'a (dyn HirDatabase + 'a),
module_id: ModuleId
) -> Result<String, DisplaySourceCodeError>
fn display_source_code(
&'a self,
db: &'a (dyn HirDatabase + 'a),
module_id: ModuleId
) -> Result<String, DisplaySourceCodeError>
Returns a String representation of self
that can be inserted into the given module.
Use this when generating code (e.g. assists) Read more
Returns a String representation of self
for test purposes
Auto Trait Implementations
impl RefUnwindSafe for Module
impl UnwindSafe for Module
Blanket Implementations
Mutably borrows from an owned value. Read more
fn cast<U>(self, interner: <U as HasInterner>::Interner) -> U where
Self: CastTo<U>,
U: HasInterner,
fn cast<U>(self, interner: <U as HasInterner>::Interner) -> U where
Self: CastTo<U>,
U: HasInterner,
Cast a value to type U
using CastTo
.
Compare self to key
and return true
if they are equal.
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more