Struct Context

Source
pub struct Context<'a, T> { /* private fields */ }
Expand description

used to lint, expand and capture

a context might not have data in it (eg. if parsing the data failed), so calling the lint and expand functions does not guarantee the Lints and Expands actually run

Implementations§

Source§

impl<'a, T> Context<'a, T>

Source

pub fn new(collector: &'a mut Collector, data: T) -> Self

create a new context with the data

Source

pub fn new_by_ref(collector: &'a mut Collector, data: &'a T) -> Self

create a new context with the data passed by reference

Source

pub fn new_empty(collector: &'a mut Collector) -> Self

create a new context without any data in it

Source

pub fn new_parse(collector: &'a mut Collector, data: TokenStream) -> Self
where T: Parse,

try to parse the data from a proc_macro::TokenStream

if parsing the data fails the error is reported to the collector

Source

pub fn new_parse2(collector: &'a mut Collector, data: TokenStream) -> Self
where T: Parse,

try to parse the data from a proc_macro2::TokenStream

if parsing the data fails the error is reported to the collector

Source

pub fn lint<L: Lint<T>>(&mut self, lint: &L) -> bool

lint the macro input

returns true if the lint ran without reporting an error

Source

pub fn expand(&mut self, expand: &impl Expand<T>)

expand the macro and add the result to the collector

Source

pub fn capture<E: Expand<T>>(&mut self, expand: &E) -> Option<E::Output>

expand the macro and return the output

Auto Trait Implementations§

§

impl<'a, T> Freeze for Context<'a, T>
where T: Freeze,

§

impl<'a, T> RefUnwindSafe for Context<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> !Send for Context<'a, T>

§

impl<'a, T> !Sync for Context<'a, T>

§

impl<'a, T> Unpin for Context<'a, T>
where T: Unpin,

§

impl<'a, T> !UnwindSafe for Context<'a, T>

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, 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.