Enum rustc_ast::ast::NestedMetaItem
source · Expand description
Possible values inside of compile-time attribute lists.
E.g., the ‘..’ in #[name(..)]
.
Variants
MetaItem(MetaItem)
A full MetaItem, for recursive meta items.
Literal(Lit)
A literal.
E.g., "foo"
, 64
, true
.
Implementations
sourceimpl NestedMetaItem
impl NestedMetaItem
sourcepub fn meta_item(&self) -> Option<&MetaItem>
pub fn meta_item(&self) -> Option<&MetaItem>
Returns the MetaItem
if self
is a NestedMetaItem::MetaItem
.
sourcepub fn has_name(&self, name: Symbol) -> bool
pub fn has_name(&self, name: Symbol) -> bool
Returns true
if this list item is a MetaItem with a name of name
.
sourcepub fn ident(&self) -> Option<Ident>
pub fn ident(&self) -> Option<Ident>
For a single-segment meta item, returns its name; otherwise, returns None
.
pub fn name_or_empty(&self) -> Symbol
sourcepub fn value_str(&self) -> Option<Symbol>
pub fn value_str(&self) -> Option<Symbol>
Gets the string value if self
is a MetaItem
and the MetaItem
is a
MetaItemKind::NameValue
variant containing a string, otherwise None
.
sourcepub fn name_value_literal(&self) -> Option<(Symbol, &Lit)>
pub fn name_value_literal(&self) -> Option<(Symbol, &Lit)>
Returns a name and single literal value tuple of the MetaItem
.
sourcepub fn meta_item_list(&self) -> Option<&[NestedMetaItem]>
pub fn meta_item_list(&self) -> Option<&[NestedMetaItem]>
Gets a list of inner meta items from a list MetaItem
type.
sourcepub fn is_meta_item(&self) -> bool
pub fn is_meta_item(&self) -> bool
Returns true
if the variant is MetaItem
.
sourcepub fn name_value_literal_span(&self) -> Option<Span>
pub fn name_value_literal_span(&self) -> Option<Span>
sourceimpl NestedMetaItem
impl NestedMetaItem
pub fn span(&self) -> Span
fn token_trees(&self) -> Vec<TokenTree>
fn from_tokens<I>(tokens: &mut Peekable<I>) -> Option<NestedMetaItem>where
I: Iterator<Item = TokenTree>,
Trait Implementations
sourceimpl Clone for NestedMetaItem
impl Clone for NestedMetaItem
sourcefn clone(&self) -> NestedMetaItem
fn clone(&self) -> NestedMetaItem
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl Debug for NestedMetaItem
impl Debug for NestedMetaItem
sourceimpl<__D: Decoder> Decodable<__D> for NestedMetaItem
impl<__D: Decoder> Decodable<__D> for NestedMetaItem
sourceimpl<__E: Encoder> Encodable<__E> for NestedMetaItem
impl<__E: Encoder> Encodable<__E> for NestedMetaItem
sourceimpl<__CTX> HashStable<__CTX> for NestedMetaItemwhere
__CTX: HashStableContext,
impl<__CTX> HashStable<__CTX> for NestedMetaItemwhere
__CTX: HashStableContext,
fn hash_stable(&self, __hcx: &mut __CTX, __hasher: &mut StableHasher)
Auto Trait Implementations
impl !RefUnwindSafe for NestedMetaItem
impl !Send for NestedMetaItem
impl !Sync for NestedMetaItem
impl Unpin for NestedMetaItem
impl !UnwindSafe for NestedMetaItem
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Layout
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 96 bytes
Size for each variant:
MetaItem
: 96 bytesLiteral
: 48 bytes