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§
Sourcefn path(&self) -> SimplePath
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.
Sourcefn apply(&self, attr: Attribute, scope: &mut Scope) -> Result<()>
fn apply(&self, attr: Attribute, scope: &mut Scope) -> Result<()>
Function type of ScopeAttr
rule
Input arguments:
attr
: the invoking attribute. It is suggested to parse arguments usingAttribute::parse_args
orAttribute::parse_args_with
.scope
: mutable reference to the implementation scope. Usually an attribute rule function will read data from the scope and append its output toScope::generated
.
Provided Methods§
Sourcefn support_repetition(&self) -> bool
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.