pub enum IdentOrIndex {
Ident {
ident: Ident,
attributes: Vec<Attribute>,
},
Index {
index: usize,
span: Span,
attributes: 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 IdentOrIndex
impl IdentOrIndex
Sourcepub fn unwrap_ident(&self) -> Ident
pub fn unwrap_ident(&self) -> 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 Clone for IdentOrIndex
impl Clone for IdentOrIndex
Source§fn clone(&self) -> IdentOrIndex
fn clone(&self) -> IdentOrIndex
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for IdentOrIndex
impl Debug for IdentOrIndex
Auto Trait Implementations§
impl Freeze for IdentOrIndex
impl RefUnwindSafe for IdentOrIndex
impl !Send for IdentOrIndex
impl !Sync for IdentOrIndex
impl Unpin for IdentOrIndex
impl UnsafeUnpin for IdentOrIndex
impl UnwindSafe for IdentOrIndex
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