pub struct Mod {
pub submods: BTreeMap<Ident, Mod>,
pub items: TokenStream,
pub traits: BTreeMap<Ident, Trait>,
pub impls: BTreeMap<(Vec<Ident>, Ident), TokenStream>,
}
Expand description
A representation of a module definition that we will eventually emit. This is used to allow easily adding onto the module each time we see a relevant decl.
Fields§
§submods: BTreeMap<Ident, Mod>
§items: TokenStream
§traits: BTreeMap<Ident, Trait>
§impls: BTreeMap<(Vec<Ident>, Ident), TokenStream>
Implementations§
Source§impl Mod
impl Mod
pub fn empty() -> Self
Sourcepub fn submod<'a>(&'a mut self, i: Ident) -> &'a mut Self
pub fn submod<'a>(&'a mut self, i: Ident) -> &'a mut Self
Get a reference to a sub-module, creating it if necessary
Sourcepub fn submod_immut<'a>(&'a self, i: Ident) -> &'a Self
pub fn submod_immut<'a>(&'a self, i: Ident) -> &'a Self
Get an immutable reference to a sub-module
Precondition: the named submodule must already exist
Sourcepub fn trait<'a>(&'a mut self, i: Ident) -> &'a mut Trait
pub fn trait<'a>(&'a mut self, i: Ident) -> &'a mut Trait
Get a reference to a trait definition in this module, creating it if necessary
Sourcepub fn trait_immut<'a>(&'a self, i: Ident) -> &'a Trait
pub fn trait_immut<'a>(&'a self, i: Ident) -> &'a Trait
Get an immutable reference to a trait definition in this module
Precondition: the named trait must already exist
Sourcepub fn impl<'a>(&'a mut self, t: Vec<Ident>, i: Ident) -> &'a mut TokenStream
pub fn impl<'a>(&'a mut self, t: Vec<Ident>, i: Ident) -> &'a mut TokenStream
Get a reference to an impl block that is in this module, creating it if necessary.
Currently, we don’t track much information about these, so it’s just a mutable token stream.
Sourcepub fn adjust_vars(&mut self, n: u32)
pub fn adjust_vars(&mut self, n: u32)
See State::adjust_vars
.
Sourcepub fn into_tokens(self) -> TokenStream
pub fn into_tokens(self) -> TokenStream
Build a token stream for this entire module
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Mod
impl RefUnwindSafe for Mod
impl !Send for Mod
impl !Sync for Mod
impl Unpin for Mod
impl UnwindSafe for Mod
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> 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>
Converts
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>
Converts
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