pub struct Trait {
pub supertraits: BTreeMap<Vec<Ident>, TokenStream>,
pub tvs: BTreeMap<Ident, (Option<u32>, TokenStream)>,
pub items: TokenStream,
}
Expand description
A representation of a trait definition that we will eventually emit. This is used to allow easily adding onto the trait each time we see an extern decl.
Fields§
§supertraits: BTreeMap<Vec<Ident>, TokenStream>
A set of supertrait constraints, each associated with a bindings module path
tvs: BTreeMap<Ident, (Option<u32>, TokenStream)>
Keep track for each type variable of:
- The identifier that we use for it in the generated source
- Whether it comes from a component type variable, and if so, which one. (Most do; the I: Imports on the main component trait is the main one that doesn’t).
- Whether there are any bounds on it
items: TokenStream
Raw tokens of the contents of the trait
Implementations§
Source§impl Trait
impl Trait
pub fn new() -> Self
Sourcepub fn tv_idxs(&self) -> Vec<u32>
pub fn tv_idxs(&self) -> Vec<u32>
Collect the component tyvar indices that correspond to the type variables on this trait.
Precondition: all of the type variables on this trait do correspond to component variables.
Sourcepub fn adjust_vars(&mut self, n: u32)
pub fn adjust_vars(&mut self, n: u32)
See State::adjust_vars
.
Sourcepub fn tv_toks_inner(&mut self) -> TokenStream
pub fn tv_toks_inner(&mut self) -> TokenStream
Build a token stream of all type variables and trait bounds on them, e.g. what you would put “inside” the <> in trait T<…>.
Sourcepub fn tv_toks(&mut self) -> TokenStream
pub fn tv_toks(&mut self) -> TokenStream
Build a token stream for the type variable part of the trait declaration
Sourcepub fn into_tokens(&mut self, n: Ident) -> TokenStream
pub fn into_tokens(&mut self, n: Ident) -> TokenStream
Build a token stream for this entire trait definition
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Trait
impl RefUnwindSafe for Trait
impl !Send for Trait
impl !Sync for Trait
impl Unpin for Trait
impl UnwindSafe for Trait
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
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