Skip to main content

AttributeExt

Trait AttributeExt 

Source
pub trait AttributeExt: Debug + 'static {
    // Required methods
    fn name(&self) -> Option<Symbol>;
    fn value_str(&self) -> Option<Symbol>;
    fn path_matches(&self, name: &[Symbol]) -> bool;
    fn doc_str_and_fragment_kind(
        &self,
    ) -> Option<(Symbol, DocFragmentKind, Span)>;
    fn doc_resolution_scope(&self) -> Option<AttrStyle>;
}

Required Methods§

Source

fn name(&self) -> Option<Symbol>

For a single-segment attribute (i.e., #[attr] and not #[path::atrr]), return the name of the attribute; otherwise, returns None.

Source

fn value_str(&self) -> Option<Symbol>

Gets the value literal, as string, when using #[attr = value]

Source

fn path_matches(&self, name: &[Symbol]) -> bool

Checks whether the path of this attribute matches the name.

Matches one segment of the path to each element in name

Source

fn doc_str_and_fragment_kind(&self) -> Option<(Symbol, DocFragmentKind, Span)>

Returns the documentation and its kind if this is a doc comment or a sugared doc comment.

  • ///doc returns Some(("doc", CommentKind::Line)).
  • /** doc */ returns Some(("doc", CommentKind::Block)).
  • #[doc = "doc"] returns Some(("doc", CommentKind::Line)).
  • #[doc(...)] returns None.
Source

fn doc_resolution_scope(&self) -> Option<AttrStyle>

Returns outer or inner if this is a doc attribute or a sugared doc comment, otherwise None.

This is used in the case of doc comments on modules, to decide whether to resolve intra-doc links against the symbols in scope within the commented module (for inner doc) vs within its parent module (for outer doc).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§