Trait impl_tools_lib::ScopeAttr
source · [−]pub trait ScopeAttr {
fn path(&self) -> SimplePath;
fn apply(&self, attr: Attribute, scope: &mut Scope) -> Result<()>;
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
fn 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.
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
fn 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.