pub struct Module { /* private fields */ }
Implementations§
source§impl Module
impl Module
NB: Module is !HasSource, because it has two source nodes at the same time: definition and declaration.
sourcepub fn definition_source(self, db: &dyn HirDatabase) -> InFile<ModuleSource>
pub fn definition_source(self, db: &dyn HirDatabase) -> InFile<ModuleSource>
Returns a node which defines this module. That is, a file or a mod foo {}
with items.
sourcepub fn definition_source_range(self, db: &dyn HirDatabase) -> InFile<TextRange>
pub fn definition_source_range(self, db: &dyn HirDatabase) -> InFile<TextRange>
Returns a node which defines this module. That is, a file or a mod foo {}
with items.
pub fn definition_source_file_id(self, db: &dyn HirDatabase) -> HirFileId
pub fn is_mod_rs(self, db: &dyn HirDatabase) -> bool
pub fn as_source_file_id(self, db: &dyn HirDatabase) -> Option<EditionedFileId>
pub fn is_inline(self, db: &dyn HirDatabase) -> bool
sourcepub fn declaration_source(self, db: &dyn HirDatabase) -> Option<InFile<Module>>
pub fn declaration_source(self, db: &dyn HirDatabase) -> Option<InFile<Module>>
Returns a node which declares this module, either a mod foo;
or a mod foo {}
.
None
for the crate root.
sourcepub fn declaration_source_range(
self,
db: &dyn HirDatabase,
) -> Option<InFile<TextRange>>
pub fn declaration_source_range( self, db: &dyn HirDatabase, ) -> Option<InFile<TextRange>>
Returns a text range which declares this module, either a mod foo;
or a mod foo {}
.
None
for the crate root.
source§impl Module
impl Module
sourcepub fn name(self, db: &dyn HirDatabase) -> Option<Name>
pub fn name(self, db: &dyn HirDatabase) -> Option<Name>
Name of this module.
sourcepub fn crate_root(self, db: &dyn HirDatabase) -> Module
pub fn crate_root(self, db: &dyn HirDatabase) -> 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
.
pub fn is_crate_root(self) -> bool
sourcepub fn children(self, db: &dyn HirDatabase) -> impl Iterator<Item = Module>
pub fn children(self, db: &dyn HirDatabase) -> impl Iterator<Item = Module>
Iterates over all child modules.
sourcepub fn parent(self, db: &dyn HirDatabase) -> Option<Module>
pub fn parent(self, db: &dyn HirDatabase) -> Option<Module>
Finds a parent module.
sourcepub fn nearest_non_block_module(self, db: &dyn HirDatabase) -> Module
pub fn nearest_non_block_module(self, db: &dyn HirDatabase) -> Module
Finds nearest non-block ancestor Module
(self
included).
pub fn path_to_root(self, db: &dyn HirDatabase) -> Vec<Module>
sourcepub fn scope(
self,
db: &dyn HirDatabase,
visible_from: Option<Module>,
) -> Vec<(Name, ScopeDef)>
pub fn scope( self, db: &dyn HirDatabase, visible_from: Option<Module>, ) -> Vec<(Name, ScopeDef)>
Returns a ModuleScope
: a set of items, visible in this module.
sourcepub fn diagnostics(
self,
db: &dyn HirDatabase,
acc: &mut Vec<AnyDiagnostic>,
style_lints: bool,
)
pub fn diagnostics( self, db: &dyn HirDatabase, acc: &mut Vec<AnyDiagnostic>, style_lints: bool, )
Fills acc
with the module’s diagnostics.
pub fn declarations(self, db: &dyn HirDatabase) -> Vec<ModuleDef>
pub fn legacy_macros(self, db: &dyn HirDatabase) -> Vec<Macro>
pub fn impl_defs(self, db: &dyn HirDatabase) -> Vec<Impl>
sourcepub fn find_path(
self,
db: &dyn DefDatabase,
item: impl Into<ItemInNs>,
cfg: ImportPathConfig,
) -> Option<ModPath>
pub fn find_path( self, db: &dyn DefDatabase, item: impl Into<ItemInNs>, cfg: ImportPathConfig, ) -> Option<ModPath>
Finds a path that can be used to refer to the given item from within this module, if possible.
sourcepub fn find_use_path(
self,
db: &dyn DefDatabase,
item: impl Into<ItemInNs>,
prefix_kind: PrefixKind,
cfg: ImportPathConfig,
) -> Option<ModPath>
pub fn find_use_path( self, db: &dyn DefDatabase, item: impl Into<ItemInNs>, prefix_kind: PrefixKind, cfg: ImportPathConfig, ) -> 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§
source§impl HasAttrs for Module
impl HasAttrs for Module
fn attrs(self, db: &dyn HirDatabase) -> AttrsWithOwner
source§impl HasContainer for Module
impl HasContainer for Module
fn container(&self, db: &dyn HirDatabase) -> ItemContainer
source§impl HasVisibility for Module
impl HasVisibility for Module
fn visibility(&self, db: &dyn HirDatabase) -> Visibility
fn is_visible_from(&self, db: &dyn HirDatabase, module: Module) -> bool
source§impl HirDisplay for Module
impl HirDisplay for Module
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError>
§fn into_displayable<'a>(
&'a self,
db: &'a dyn HirDatabase,
max_size: Option<usize>,
limited_size: Option<usize>,
omit_verbose_types: bool,
display_target: DisplayTarget,
closure_style: ClosureStyle,
show_container_bounds: bool,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
fn into_displayable<'a>(
&'a self,
db: &'a dyn HirDatabase,
max_size: Option<usize>,
limited_size: Option<usize>,
omit_verbose_types: bool,
display_target: DisplayTarget,
closure_style: ClosureStyle,
show_container_bounds: bool,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
Display
able type that is human-readable.§fn display<'a>(
&'a self,
db: &'a dyn HirDatabase,
edition: Edition,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
fn display<'a>(
&'a self,
db: &'a dyn HirDatabase,
edition: Edition,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
Display
able type that is human-readable.
Use this for showing types to the user (e.g. diagnostics)§fn display_truncated<'a>(
&'a self,
db: &'a dyn HirDatabase,
max_size: Option<usize>,
edition: Edition,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
fn display_truncated<'a>(
&'a self,
db: &'a dyn HirDatabase,
max_size: Option<usize>,
edition: Edition,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
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)§fn display_limited<'a>(
&'a self,
db: &'a dyn HirDatabase,
limited_size: Option<usize>,
edition: Edition,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
fn display_limited<'a>(
&'a self,
db: &'a dyn HirDatabase,
limited_size: Option<usize>,
edition: Edition,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
Display
able type that is human-readable and tries to limit the number of items inside.
Use this for showing definitions which may contain too many items, like trait
, struct
, enum
§fn display_source_code<'a>(
&'a self,
db: &'a dyn HirDatabase,
module_id: ModuleId,
allow_opaque: bool,
) -> Result<String, DisplaySourceCodeError>
fn display_source_code<'a>( &'a self, db: &'a dyn HirDatabase, module_id: ModuleId, allow_opaque: bool, ) -> Result<String, DisplaySourceCodeError>
self
that can be inserted into the given module.
Use this when generating code (e.g. assists)§fn display_test<'a>(
&'a self,
db: &'a dyn HirDatabase,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
fn display_test<'a>(
&'a self,
db: &'a dyn HirDatabase,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
self
for test purposes§fn display_with_container_bounds<'a>(
&'a self,
db: &'a dyn HirDatabase,
show_container_bounds: bool,
edition: Edition,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
fn display_with_container_bounds<'a>(
&'a self,
db: &'a dyn HirDatabase,
show_container_bounds: bool,
edition: Edition,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
self
that shows the constraint from
the container for functionsimpl Copy for Module
impl Eq for Module
impl StructuralPartialEq for Module
Auto Trait Implementations§
impl Freeze for Module
impl RefUnwindSafe for Module
impl Send for Module
impl Sync for Module
impl Unpin for Module
impl UnwindSafe for Module
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
§impl<T> Cast for T
impl<T> Cast for T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more