SubstDetails

Enum SubstDetails 

Source
pub enum SubstDetails<O: SubstParseContext> {
Show 54 variants tname(O::NotInBool), ttype(O::NotInBool), tdeftype(O::NotInBool), vname(O::NotInBool), fname(O::NotInBool), ftype(O::NotInBool), fpatname(O::NotInBool), Vis(SubstVis, (<O as SubstParseContext>::NotInPaste, <O as SubstParseContext>::NotInConcat)), tdefkwd(O::NotInBool), vindex(O::NotInBool, Enabled), findex(O::NotInBool, Enabled), Xmeta(SubstMeta<O>), tattrs(RawAttr, (<O as SubstParseContext>::NotInPaste, <O as SubstParseContext>::NotInConcat), O::NotInBool), vattrs(RawAttr, (<O as SubstParseContext>::NotInPaste, <O as SubstParseContext>::NotInConcat), O::NotInBool), fattrs(RawAttr, (<O as SubstParseContext>::NotInPaste, <O as SubstParseContext>::NotInConcat), O::NotInBool), tgens((<O as SubstParseContext>::NotInPaste, <O as SubstParseContext>::NotInConcat)), tdefgens((<O as SubstParseContext>::NotInPaste, <O as SubstParseContext>::NotInConcat), O::NotInBool), tgnames((<O as SubstParseContext>::NotInPaste, <O as SubstParseContext>::NotInConcat), O::NotInBool), twheres((<O as SubstParseContext>::NotInPaste, <O as SubstParseContext>::NotInConcat), O::NotInBool), vpat(SubstVPat, (<O as SubstParseContext>::NotInPaste, <O as SubstParseContext>::NotInConcat), O::NotInBool), vtype(SubstVType, (<O as SubstParseContext>::NotInPaste, <O as SubstParseContext>::NotInConcat), O::NotInBool), tdefvariants(Template<TokenAccumulator>, (<O as SubstParseContext>::NotInPaste, <O as SubstParseContext>::NotInConcat), O::NotInBool), fdefine(Option<Argument>, (<O as SubstParseContext>::NotInPaste, <O as SubstParseContext>::NotInConcat), O::NotInBool), vdefbody(Argument<O>, Template<TokenAccumulator>, (<O as SubstParseContext>::NotInPaste, <O as SubstParseContext>::NotInConcat), O::NotInBool), paste(Template<Items>, O::NotInBool), paste_spanned(Argument, Argument<Items>, O::NotInBool, Enabled), ChangeCase(Template<Items>, ChangeCase, ChangeCaseOkIn<O>), concat(Template<Accumulator>, O::NotInBool, O::NotInPaste, Enabled), when(Box<Subst<BooleanContext>>, O::NotInBool), define(Definition<DefinitionBody>, O::NotInBool), defcond(Definition<Box<Subst<BooleanContext>>>, O::NotInBool), UserDefined(DefinitionName), False(O::BoolOnly), True(O::BoolOnly), not(Box<Subst<BooleanContext>>, O::BoolOnly), any(Punctuated<Subst<BooleanContext>, Comma>, O::BoolOnly), all(Punctuated<Subst<BooleanContext>, Comma>, O::BoolOnly), is_struct(O::BoolOnly), is_enum(O::BoolOnly), is_union(O::BoolOnly), v_is_unit(O::BoolOnly), v_is_tuple(O::BoolOnly), v_is_named(O::BoolOnly), is_empty(O::BoolOnly, Template<TokenAccumulator>), approx_equal(O::BoolOnly, [Argument; 2]), For(RepeatedTemplate<O>, O::NotInBool), If(SubstIf<O>, O::NotInBool), select1(SubstIf<O>, O::NotInBool), ignore(Template<O>, O::NotInBool), error(ExplicitError, O::NotInBool), require_beta(Enabled, O::NotInBool), dbg(DbgDumpRequest<O>), dbg_all_keywords(O::NotInBool), Crate((<O as SubstParseContext>::NotInPaste, <O as SubstParseContext>::NotInConcat), O::NotInBool),
}
Expand description

Enum representing nature and payload of a substitution

This is a single enum, for all of the different lexical contexts (principal expansion, identifier pasting, boolean predicates) because this:

  • Unifies the parsing code, ensuring that all these constructs are parsed the same everywhere (unless we deviate deliberately).
  • Mostly unifies the expansion and loop/conditional walking code.
  • Avoids the need to recapitulate the keywords in multiple enums, or contexts with inner nested enums, or something.

The enum is generic over the lexical context SubstParseContext. This allows the variants that are inapplicable in a particular lexical context to be made uninhabited: that ensures that detection of such errors occurs during template parsing.

Variants§

§

tname(O::NotInBool)

§

ttype(O::NotInBool)

§

tdeftype(O::NotInBool)

§

vname(O::NotInBool)

§

fname(O::NotInBool)

§

ftype(O::NotInBool)

§

fpatname(O::NotInBool)

§

Vis(SubstVis, (<O as SubstParseContext>::NotInPaste, <O as SubstParseContext>::NotInConcat))

§

tdefkwd(O::NotInBool)

§

vindex(O::NotInBool, Enabled)

§

findex(O::NotInBool, Enabled)

§

Xmeta(SubstMeta<O>)

§

tattrs(RawAttr, (<O as SubstParseContext>::NotInPaste, <O as SubstParseContext>::NotInConcat), O::NotInBool)

§

vattrs(RawAttr, (<O as SubstParseContext>::NotInPaste, <O as SubstParseContext>::NotInConcat), O::NotInBool)

§

fattrs(RawAttr, (<O as SubstParseContext>::NotInPaste, <O as SubstParseContext>::NotInConcat), O::NotInBool)

§

tgens((<O as SubstParseContext>::NotInPaste, <O as SubstParseContext>::NotInConcat))

§

tdefgens((<O as SubstParseContext>::NotInPaste, <O as SubstParseContext>::NotInConcat), O::NotInBool)

§

tgnames((<O as SubstParseContext>::NotInPaste, <O as SubstParseContext>::NotInConcat), O::NotInBool)

§

twheres((<O as SubstParseContext>::NotInPaste, <O as SubstParseContext>::NotInConcat), O::NotInBool)

§

vpat(SubstVPat, (<O as SubstParseContext>::NotInPaste, <O as SubstParseContext>::NotInConcat), O::NotInBool)

§

vtype(SubstVType, (<O as SubstParseContext>::NotInPaste, <O as SubstParseContext>::NotInConcat), O::NotInBool)

§

tdefvariants(Template<TokenAccumulator>, (<O as SubstParseContext>::NotInPaste, <O as SubstParseContext>::NotInConcat), O::NotInBool)

§

fdefine(Option<Argument>, (<O as SubstParseContext>::NotInPaste, <O as SubstParseContext>::NotInConcat), O::NotInBool)

§

vdefbody(Argument<O>, Template<TokenAccumulator>, (<O as SubstParseContext>::NotInPaste, <O as SubstParseContext>::NotInConcat), O::NotInBool)

§

paste(Template<Items>, O::NotInBool)

§

paste_spanned(Argument, Argument<Items>, O::NotInBool, Enabled)

§

ChangeCase(Template<Items>, ChangeCase, ChangeCaseOkIn<O>)

§

concat(Template<Accumulator>, O::NotInBool, O::NotInPaste, Enabled)

§

when(Box<Subst<BooleanContext>>, O::NotInBool)

§

define(Definition<DefinitionBody>, O::NotInBool)

§

defcond(Definition<Box<Subst<BooleanContext>>>, O::NotInBool)

§

UserDefined(DefinitionName)

§

False(O::BoolOnly)

§

True(O::BoolOnly)

§

not(Box<Subst<BooleanContext>>, O::BoolOnly)

§

any(Punctuated<Subst<BooleanContext>, Comma>, O::BoolOnly)

§

all(Punctuated<Subst<BooleanContext>, Comma>, O::BoolOnly)

§

is_struct(O::BoolOnly)

§

is_enum(O::BoolOnly)

§

is_union(O::BoolOnly)

§

v_is_unit(O::BoolOnly)

§

v_is_tuple(O::BoolOnly)

§

v_is_named(O::BoolOnly)

§

is_empty(O::BoolOnly, Template<TokenAccumulator>)

§

approx_equal(O::BoolOnly, [Argument; 2])

§

For(RepeatedTemplate<O>, O::NotInBool)

§

If(SubstIf<O>, O::NotInBool)

§

select1(SubstIf<O>, O::NotInBool)

§

ignore(Template<O>, O::NotInBool)

§

error(ExplicitError, O::NotInBool)

§

require_beta(Enabled, O::NotInBool)

§

dbg(DbgDumpRequest<O>)

§

dbg_all_keywords(O::NotInBool)

§

Crate((<O as SubstParseContext>::NotInPaste, <O as SubstParseContext>::NotInConcat), O::NotInBool)

Implementations§

Source§

impl<O> SubstDetails<O>

Source

fn expand<'c>( &self, gctx: GeneralContext<'c>, out: &mut O, kw_span: Span, ) -> Result<()>

Expand this template element, by adding it to O

This is done using O’s ExpansionOutput methods.

Trait Implementations§

Source§

impl<O: Debug + SubstParseContext> Debug for SubstDetails<O>

Source§

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

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

impl<O: SubstParseContext> FindRecogMetas for SubstDetails<O>

Source§

fn find_recog_metas(&self, acc: &mut Recognised)

Search for fmeta(..) etc. expansions Read more

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
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.