pub struct FormatArgs { /* private fields */ }Expand description
A format specification: A format string followed by arguments to be formatted in accordance with that string.
This type can only be built inside of a macro context since it performs constant evaluation.
Both the format string and the arguments are held as the tokens they were
written as rather than as a syntax tree, so nothing here recurses over what
a macro was handed - see MacroContext::exprs.
Implementations§
Source§impl FormatArgs
impl FormatArgs
Sourcepub fn parse(
cx: &mut MacroContext<'_, '_, '_>,
stream: &TokenStream,
) -> Result<Self>
pub fn parse( cx: &mut MacroContext<'_, '_, '_>, stream: &TokenStream, ) -> Result<Self>
Parse format arguments out of the whole input of a macro.
§Examples
use rune::macros::{self, quote, FormatArgs};
macros::test(|cx| {
let stream = quote!("Hello {}", 42).into_token_stream(cx)?;
let args = FormatArgs::parse(cx, &stream)?;
let expanded = args.expand(cx)?.into_token_stream(cx)?;
assert!(expanded.kinds().count() > 0);
Ok(())
})?;Sourcepub fn from_exprs<I>(
cx: &mut MacroContext<'_, '_, '_>,
exprs: I,
) -> Result<Self>where
I: IntoIterator<Item = TokenStream>,
pub fn from_exprs<I>(
cx: &mut MacroContext<'_, '_, '_>,
exprs: I,
) -> Result<Self>where
I: IntoIterator<Item = TokenStream>,
Build format arguments out of expressions which have already been split
out of the input of a macro with MacroContext::exprs.
This is what a macro whose format specification is preceded by
arguments of its own uses, assert! being one.
Sourcepub fn expand(&self, cx: &mut MacroContext<'_, '_, '_>) -> Result<Quote<'_>>
pub fn expand(&self, cx: &mut MacroContext<'_, '_, '_>) -> Result<Quote<'_>>
Expand the format specification.
Auto Trait Implementations§
impl Forget for FormatArgs
impl Freeze for FormatArgswhere
*const Token is !null: Freeze,
PhantomData<Token>: Freeze,
*const FormatArg is !null: Freeze,
PhantomData<FormatArg>: Freeze,
impl Move for FormatArgs
impl RefUnwindSafe for FormatArgs
impl Send for FormatArgs
impl Sync for FormatArgs
impl Unpin for FormatArgs
impl UnsafeUnpin for FormatArgswhere
*const Token is !null: UnsafeUnpin,
PhantomData<Token>: UnsafeUnpin,
*const FormatArg is !null: UnsafeUnpin,
PhantomData<FormatArg>: UnsafeUnpin,
impl UnwindSafe for FormatArgswhere
NonNull<Token>: UnwindSafe,
NonZero<u32>: UnwindSafe,
NonNull<FormatArg>: UnwindSafe,
NonNull<str>: UnwindSafe,
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
Mutably borrows from an owned value. Read more