pub struct Context<'c> {
pub top: &'c DeriveInput,
pub template_crate: &'c Path,
pub template_name: Option<&'c Path>,
pub pmetas: &'c Vec<PreprocessedValueList>,
pub variant: Option<&'c WithinVariant<'c>>,
pub field: Option<&'c WithinField<'c>>,
pub within_loop: WithinLoop,
pub pvariants: &'c [PreprocessedVariant<'c>],
pub defs: DefinitionsContext<'c>,
}Expand description
Context during expansion
References the driver, and digested information about it. Also represents where in the driver we are, including repetition context.
Fields§
§top: &'c DeriveInput§template_crate: &'c Path§template_name: Option<&'c Path>§pmetas: &'c Vec<PreprocessedValueList>§variant: Option<&'c WithinVariant<'c>>§field: Option<&'c WithinField<'c>>§within_loop: WithinLoop§pvariants: &'c [PreprocessedVariant<'c>]§defs: DefinitionsContext<'c>Implementations§
Source§impl<'c> Context<'c>
impl<'c> Context<'c>
pub fn as_general(&'c self) -> GeneralContext<'c>
Source§impl<'c> Context<'c>
impl<'c> Context<'c>
pub fn decode_update_metas_used(&self, input: ParseStream<'_>) -> Result<()>
Source§impl<'c> Context<'c>
impl<'c> Context<'c>
Sourcepub fn encode_metas_used(&self) -> Group
pub fn encode_metas_used(&self) -> Group
Returns [::Variant .field () ...]
Source§impl<'c> Context<'c>
impl<'c> Context<'c>
pub(crate) fn check_metas_used( &self, errors: &mut ErrorAccumulator, recog: &Recognised, )
Source§impl<'c> Context<'c>
impl<'c> Context<'c>
Sourcepub fn error_loc(&self) -> (Span, &'static str)
pub fn error_loc(&self) -> (Span, &'static str)
Returns an ErrorLoc for the current part of the driver
Sourcepub fn for_with_within<'w, W, F, E>(&'c self, call: F) -> Result<(), E>
pub fn for_with_within<'w, W, F, E>(&'c self, call: F) -> Result<(), E>
Obtains the relevant Within(s), and calls call for each one
If there is a current W, simply calls call.
Otherwise, iterates over all of them and calls call for each one.
Sourcefn within_level<W>(&'c self, why: &dyn Spanned) -> Result<&'c W>where
W: WithinRepeatLevel<'c>,
fn within_level<W>(&'c self, why: &dyn Spanned) -> Result<&'c W>where
W: WithinRepeatLevel<'c>,
Obtains the current Within of type W
Demands that there actually is a current container W.
If we aren’t, calls it an error.
Sourcepub fn field(&self, why: &dyn Spanned) -> Result<&WithinField<'_>>
pub fn field(&self, why: &dyn Spanned) -> Result<&WithinField<'_>>
Obtains the current field (or calls it an error)
Sourcepub fn variant(&self, why: &dyn Spanned) -> Result<&WithinVariant<'_>>
pub fn variant(&self, why: &dyn Spanned) -> Result<&WithinVariant<'_>>
Obtains the current variant (or calls it an error)
Sourcepub fn syn_variant(&self, why: &dyn Spanned) -> Result<&Variant>
pub fn syn_variant(&self, why: &dyn Spanned) -> Result<&Variant>
Obtains the current variant as a syn::Variant
Source§impl<'c> Context<'c>
impl<'c> Context<'c>
Sourcepub fn call<T>(
driver: &DeriveInput,
template_crate: &Path,
template_name: Option<&Path>,
f: impl FnOnce(Context<'_>) -> Result<T>,
) -> Result<T, Error>
pub fn call<T>( driver: &DeriveInput, template_crate: &Path, template_name: Option<&Path>, f: impl FnOnce(Context<'_>) -> Result<T>, ) -> Result<T, Error>
Calls f with a top-level Context for a syn::DeriveInput
Context has multiple levels of references to values created
here, so we can’t easily provide Context::new().
Trait Implementations§
impl<'c> Copy for Context<'c>
Auto Trait Implementations§
impl<'c> Freeze for Context<'c>
impl<'c> !RefUnwindSafe for Context<'c>
impl<'c> !Send for Context<'c>
impl<'c> !Sync for Context<'c>
impl<'c> Unpin for Context<'c>
impl<'c> !UnwindSafe for Context<'c>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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