Reputation: 7
I'm trying to learn Rust, and want to understand everything in this code block.
#[macro_export(local_inner_macros)]
macro_rules! parse_macro_input {
($tokenstream:ident as $ty:ty) => {
match $crate::parse_macro_input::parse::<$ty>($tokenstream) {
$crate::export::Ok(data) => data,
$crate::export::Err(err) => {
return $crate::export::TokenStream::from(err.to_compile_error());
}
}
};
($tokenstream:ident) => {
parse_macro_input!($tokenstream as _)
};
}
My current issue is with ($tokenstream:ident as $ty:ty)
.
Thank you
Upvotes: 0
Views: 504
Reputation: 174
$foo:ty
is for a type,
$bar:ident
is for an identifier,
more details can be found here.Upvotes: 1