Enum virtue::parse::IdentOrIndex
source · pub enum IdentOrIndex<'a> {
Ident {
ident: &'a Ident,
attributes: &'a Vec<Attribute>,
},
Index {
index: usize,
span: Span,
attributes: &'a Vec<Attribute>,
},
}
Expand description
Reference to an enum variant’s field. Either by index or by ident.
enum Foo {
Bar(u32), // will be IdentOrIndex::Index { index: 0, .. }
Baz {
a: u32, // will be IdentOrIndex::Ident { ident: "a", .. }
},
}
Variants§
Implementations§
source§impl<'a> IdentOrIndex<'a>
impl<'a> IdentOrIndex<'a>
sourcepub fn unwrap_ident(&self) -> &'a Ident
pub fn unwrap_ident(&self) -> &'a Ident
Get the ident. Will panic if this is an IdentOrIndex::Index
sourcepub fn to_token_tree_with_prefix(&self, prefix: &str) -> TokenTree
pub fn to_token_tree_with_prefix(&self, prefix: &str) -> TokenTree
Convert this ident into a TokenTree. If this is an Index
, will return prefix + index
instead.
sourcepub fn to_string_with_prefix(&self, prefix: &str) -> String
pub fn to_string_with_prefix(&self, prefix: &str) -> String
Return either the index or the ident of this field with a fixed prefix. The prefix will always be added.
sourcepub fn attributes(&self) -> &Vec<Attribute>
pub fn attributes(&self) -> &Vec<Attribute>
Returns the attributes of this field.
Trait Implementations§
source§impl<'a> Debug for IdentOrIndex<'a>
impl<'a> Debug for IdentOrIndex<'a>
Auto Trait Implementations§
impl<'a> Freeze for IdentOrIndex<'a>
impl<'a> RefUnwindSafe for IdentOrIndex<'a>
impl<'a> !Send for IdentOrIndex<'a>
impl<'a> !Sync for IdentOrIndex<'a>
impl<'a> Unpin for IdentOrIndex<'a>
impl<'a> UnwindSafe for IdentOrIndex<'a>
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