attribute_derive

Module parsing

Source
Expand description

This module defines the traits defining how parsing works.

attribute-derive reuses the same traits for nested values and the root attribute, this is why all traits in this module are named Attribute*.

FromAttr

Main entry point. Derived via macro. Anything that can be parsed from one or multiple attributes.

AttributeNamed

Values that can be parsed named, e.g. name(<value>), name = <value>, name (as flag).

This is the default parsing mode used for fields in derived FromAttr implementations.

AttributePositional

Values that can be parsed positionally, i.e., without a name, e.g. "literal", a + b, true.

When deriving FromAttr this is enabled via putting #[attr(positional)] on the field.

impl <T: AttributeValue> FromAttr for T
impl <T: AttributeValue> AttributeNamed for T
impl <T: AttributeValue + PositionalValue> AttributePositional for T

AttributeValue

Any attribute that has the concept of a value, e.g., "positional", meta(<value>), key = <value>.

PositionalValue

Empty marker trait, defining which AttributeValue implement AttributePositional.
impl <T: AttributeMeta> AttributeValue for T

AttributeMeta

Values in function or meta style attributes, i.e., meta(<value>).

Structs§

  • Helper struct to hold a value and the ident of its property.
  • Helper struct to hold a value and the corresponding range.

Traits§

Functions§

  • Parses the name, if it matches returns Some(name) and removes the name from input, if None it does not modify the input.