pub struct Args {
pub map: HashMap<Ident, Option<Value>>,
}Expand description
A parsed set of macro attribute arguments, keyed by argument name.
Fields§
§map: HashMap<Ident, Option<Value>>Maps each argument identifier to its optional value (None when the
argument was supplied as a bare flag without a value).
Implementations§
Source§impl Args
impl Args
Sourcepub fn has(&self, ident: &str) -> bool
pub fn has(&self, ident: &str) -> bool
Returns true if an argument with the given name is present.
Sourcepub fn get(&self, ident: &str) -> Option<&Option<Value>>
pub fn get(&self, ident: &str) -> Option<&Option<Value>>
Looks up an argument by name, returning its optional value, or None
if the argument is not present.
Sourcepub fn get_value_or<T: ToTokens>(
&self,
ident: &str,
field: T,
msg: &str,
) -> Result<Option<Value>, TokenStream>
pub fn get_value_or<T: ToTokens>( &self, ident: &str, field: T, msg: &str, ) -> Result<Option<Value>, TokenStream>
Returns the value of ident: Ok(None) if the argument is absent,
Ok(Some(_)) if it has a value, or an error spanned over field with
msg if the argument is present but carries no value.
Sourcepub fn to_string_kv(&self) -> Vec<(String, String)>
pub fn to_string_kv(&self) -> Vec<(String, String)>
Returns the arguments as a list of name/value string pairs, with string literals unquoted and valueless arguments mapped to an empty string.
Trait Implementations§
Auto Trait Implementations§
impl !Send for Args
impl !Sync for Args
impl Freeze for Args
impl RefUnwindSafe for Args
impl Unpin for Args
impl UnsafeUnpin for Args
impl UnwindSafe for Args
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