pub struct Module { /* private fields */ }
Expand description
A single Module
within a Sway project.
A Module
is most commonly associated with an individual file of Sway code, e.g. a top-level
script/predicate/contract file or some library dependency whether introduced via dep
or the
[dependencies]
table of a forc
manifest.
A Module
contains a set of all items that exist within the lexical scope via declaration or
importing, along with a map of each of its submodules.
Implementations
sourceimpl Module
impl Module
pub fn default_with_constants(
constants: BTreeMap<String, ConfigTimeConstant>
) -> Result<Self, Vec1<CompileError>>
sourcepub fn submodules(&self) -> &OrdMap<String, Module>
pub fn submodules(&self) -> &OrdMap<String, Module>
Immutable access to this module’s submodules.
sourcepub fn insert_submodule(&mut self, name: String, submodule: Module)
pub fn insert_submodule(&mut self, name: String, submodule: Module)
Insert a submodule into this Module
.
sourcepub fn submodule(&self, path: &Path) -> Option<&Module>
pub fn submodule(&self, path: &Path) -> Option<&Module>
Lookup the submodule at the given path.
sourcepub fn submodule_mut(&mut self, path: &Path) -> Option<&mut Module>
pub fn submodule_mut(&mut self, path: &Path) -> Option<&mut Module>
Unique access to the submodule at the given path.
sourcepub fn star_import_with_reexports(
&mut self,
src: &Path,
dst: &Path
) -> CompileResult<()>
pub fn star_import_with_reexports(
&mut self,
src: &Path,
dst: &Path
) -> CompileResult<()>
Given a path to a src
module, create synonyms to every symbol in that module to the given
dst
module.
This is used when an import path contains an asterisk.
Paths are assumed to be relative to self
.
Methods from Deref<Target = Items>
sourcepub fn symbols(&self) -> &OrdMap<Ident, TypedDeclaration>
pub fn symbols(&self) -> &OrdMap<Ident, TypedDeclaration>
Immutable access to the inner symbol map.