pub struct MetaItem {
pub path: Path,
pub kind: MetaItemKind,
pub span: Span,
}
Expand description
A spanned compile-time attribute item.
E.g., #[test]
, #[derive(..)]
, #[rustfmt::skip]
or #[feature = "foo"]
.
Fields
path: Path
kind: MetaItemKind
span: Span
Implementations
sourceimpl MetaItem
impl MetaItem
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
pub fn name_value_literal(&self) -> Option<&Lit>
pub fn value_str(&self) -> Option<Symbol>
pub fn meta_item_list(&self) -> Option<&[NestedMetaItem]>
pub fn is_word(&self) -> bool
pub fn has_name(&self, name: Symbol) -> bool
sourcepub fn name_value_literal_span(&self) -> Option<Span>
pub fn name_value_literal_span(&self) -> Option<Span>
This is used in case you want the value span instead of the whole attribute. Example:
#[doc(alias = "foo")]
In here, it’ll return a span for "foo"
.
Trait Implementations
sourceimpl<__CTX> HashStable<__CTX> for MetaItemwhere
__CTX: HashStableContext,
impl<__CTX> HashStable<__CTX> for MetaItemwhere
__CTX: HashStableContext,
fn hash_stable(&self, __hcx: &mut __CTX, __hasher: &mut StableHasher)
Auto Trait Implementations
impl !RefUnwindSafe for MetaItem
impl !Send for MetaItem
impl !Sync for MetaItem
impl Unpin for MetaItem
impl !UnwindSafe for MetaItem
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
Mutably borrows from an owned value. Read more
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