pub struct Equation {
pub left: Path,
pub op: Eq,
pub right: TokenStream,
}Expand description
Represents an equation parsed from a procedural macro input.
This struct models an equation consisting of a left-hand side, an operator,
and a right-hand side. The Equation is typically constructed during the
parsing process of macro input, where the left and op fields are expected
to be syntactically represented by syn::Path and syn::BinOp respectively,
indicating the variable and operation involved. The right field is a
proc_macro2::TokenStream, which can represent more complex expressions
including, but not limited to, literals, function calls, or further operations.
§Fields
-
left: The left-hand side of the equation, represented as a path. This could be a variable or a more complex path in the code being processed by the macro. -
op: The binary operator used in the equation, such as addition, subtraction, multiplication, etc. -
right: The right-hand side of the equation. Given the potential complexity of expressions on this side, it is represented as aproc_macro2::TokenStreamto accommodate any valid Rust expression.
§Examples
Parsing an equation from macro input:
use macro_tools::equation;
let got : equation::Equation = syn::parse_quote!( default = 31 );
macro_tools::tree_print!( got );
assert_eq!( macro_tools::code_to_str!( got ), "default = 31".to_string() );Fields§
§left: PathThe LHS of the equation, represented by a syntactic path.
op: EqEquality token.
right: TokenStreamThe RHS of the equation, capable of holding complex expressions.
Trait Implementations§
Source§impl ToTokens for Equation
impl ToTokens for Equation
Source§fn to_tokens(&self, tokens: &mut TokenStream)
fn to_tokens(&self, tokens: &mut TokenStream)
Source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
Source§fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
Auto Trait Implementations§
impl Freeze for Equation
impl RefUnwindSafe for Equation
impl !Send for Equation
impl !Sync for Equation
impl Unpin for Equation
impl UnwindSafe for Equation
Blanket Implementations§
Source§impl<S> AssignWithType for S
impl<S> AssignWithType for S
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<C, E> EntryToVal<C> for Ewhere
C: Collection<Entry = E>,
impl<C, E> EntryToVal<C> for Ewhere
C: Collection<Entry = E>,
Source§type Val = <C as Collection>::Val
type Val = <C as Collection>::Val
Entry in complex collections.
For example, in a HashMap, while Entry might be a ( key, value ) tuple, Val might only be the value part.Source§fn entry_to_val(self) -> <E as EntryToVal<C>>::Val
fn entry_to_val(self) -> <E as EntryToVal<C>>::Val
Source§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = Infallible
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
Source§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = Infallible
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Spanned for Twhere
T: Spanned + ?Sized,
impl<T> Spanned for Twhere
T: Spanned + ?Sized,
Source§fn span(&self) -> Span
fn span(&self) -> Span
Span covering the complete contents of this syntax tree
node, or Span::call_site() if this node is empty.Source§impl<Initial, Error, Final> TransitiveTryFrom<Error, Initial> for Final
impl<Initial, Error, Final> TransitiveTryFrom<Error, Initial> for Final
Source§impl<Error, Final, Initial> TransitiveTryInto<Error, Final> for Initial
impl<Error, Final, Initial> TransitiveTryInto<Error, Final> for Initial
Source§impl<C, Val> ValToEntry<C> for Valwhere
C: CollectionValToEntry<Val>,
impl<C, Val> ValToEntry<C> for Valwhere
C: CollectionValToEntry<Val>,
Source§fn val_to_entry(self) -> <C as CollectionValToEntry<Val>>::Entry
fn val_to_entry(self) -> <C as CollectionValToEntry<Val>>::Entry
Invokes the val_to_entry function of the CollectionValToEntry trait to convert the value to an entry.