Mod

Struct Mod 

Source
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

Source

pub fn empty() -> Self

Source

pub fn submod<'a>(&'a mut self, i: Ident) -> &'a mut Self

Get a reference to a sub-module, creating it if necessary

Source

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

Source

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

Source

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

Source

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.

Source

pub fn adjust_vars(&mut self, n: u32)

Source

pub fn into_tokens(self) -> TokenStream

Build a token stream for this entire module

Trait Implementations§

Source§

impl Debug for Mod

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Mod

Source§

fn default() -> Mod

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.