pub struct Module {
pub code: TokenStream,
pub usings: BTreeSet<String>,
pub modules: BTreeMap<String, Module>,
}Expand description
Manages the code that is generated for a specific module.
This type stores the generated code, the related using directives as well as any sub-module for a specific module generated by the code generator.
Fields§
§code: TokenStreamThe actual code that is manages by this module.
usings: BTreeSet<String>A set of using directives this module needs.
modules: BTreeMap<String, Module>A map of sub-modules contained inside this module.
Implementations§
Source§impl Module
impl Module
Sourcepub fn append(&mut self, code: TokenStream) -> &mut Self
pub fn append(&mut self, code: TokenStream) -> &mut Self
Append the passed code to this modules code.
Sourcepub fn prepend(&mut self, code: TokenStream) -> &mut Self
pub fn prepend(&mut self, code: TokenStream) -> &mut Self
Prepend the passed code to this modules code.
Sourcepub fn usings<I>(&mut self, usings: I) -> &mut Self
pub fn usings<I>(&mut self, usings: I) -> &mut Self
Add using directives to the set of this module.
Sourcepub fn module<T>(&self, ident: T) -> Option<&Module>
pub fn module<T>(&self, ident: T) -> Option<&Module>
Get a reference to a sub-module identified by the passed ident.
If the module does not exist None is returned.
Sourcepub fn module_mut<T>(&mut self, ident: T) -> &mut Module
pub fn module_mut<T>(&mut self, ident: T) -> &mut Module
Get a mutable reference to a sub-module identified by the passed ident.
If the module does not exist it will be created.
Trait Implementations§
Source§impl ToTokens for Module
impl ToTokens for Module
Source§fn to_tokens(&self, tokens: &mut TokenStream)
fn to_tokens(&self, tokens: &mut TokenStream)
Source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
Source§fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
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
Mutably borrows from an owned value. Read more