Trait ScopeAttr

Source
pub trait ScopeAttr {
    // Required methods
    fn path(&self) -> SimplePath;
    fn apply(&self, attr: Attribute, scope: &mut Scope) -> Result<()>;

    // Provided method
    fn support_repetition(&self) -> bool { ... }
}
Expand description

Attribute rule for Scope

Rules are matched via a path, e.g. &["foo"] matches foo and &["", "foo", "bar"] matches ::foo::bar.

Such rules are used to expand attributes within an impl_scope!.

Required Methods§

Source

fn path(&self) -> SimplePath

Attribute path

Rules are matched via a path, e.g. &["foo"] matches foo and &["", "foo", "bar"] matches ::foo::bar.

Note that we cannot use standard path resolution, so we match only a single path, as defined.

Source

fn apply(&self, attr: Attribute, scope: &mut Scope) -> Result<()>

Function type of ScopeAttr rule

Input arguments:

Provided Methods§

Source

fn support_repetition(&self) -> bool

Whether repeated application is valid

If this is false (the default), then an error will be omitted on repeated usage of the attribute. This mostly serves to emit better error messages in cases where the first application modifies the input.

Implementors§