Trait attribute_derive::parsing::AttributeNamed

source ·
pub trait AttributeNamed: AttributeBase {
    const PREFERRED_OPEN_DELIMITER: &'static str = " = ";
    const PREFERRED_CLOSE_DELIMITER: &'static str = "";

    // Required method
    fn parse_named(
        name: &'static str,
        input: ParseStream<'_>,
    ) -> Result<Option<Named<SpannedValue<Self::Partial>>>>;
}
Expand description

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.

Provided Associated Constants§

source

const PREFERRED_OPEN_DELIMITER: &'static str = " = "

What open delimiter to use when providing error messages.

For <name> = <value>, this is " = ", for <function>(<like>), it is "(".

As named attributes can allow both <name> = <value> and name(<value>), this might not be the only way this attribute can be used.

source

const PREFERRED_CLOSE_DELIMITER: &'static str = ""

What close delimiter to use when providing error messages.

For <name> = <value>, this is "", for <function>(<like>), it is ")".

As named attributes can allow both <name> = <value> and <name>(<value>), this might not be the only way this attribute can be used.

Required Methods§

source

fn parse_named( name: &'static str, input: ParseStream<'_>, ) -> Result<Option<Named<SpannedValue<Self::Partial>>>>

Parses an attribute containing Self called name.

While this function can be implemented freely, the provided implementations support <name> = <value>, <function>(<like>) and <flag>.

Note: This needs to stop parsing at the end of the value, before a possible following , and further arguments.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl AttributeNamed for bool

source§

fn parse_named( name: &'static str, input: ParseStream<'_>, ) -> Result<Option<Named<SpannedValue<Self::Partial>>>>

source§

impl<T: AttributeNamed> AttributeNamed for Option<T>

source§

fn parse_named( name: &'static str, input: ParseStream<'_>, ) -> Result<Option<Named<SpannedValue<Self::Partial>>>>

Implementors§

source§

impl<T: AttributeValue> AttributeNamed for FlagOrValue<T>

source§

impl<T: AttributeValue> AttributeNamed for T

source§

const PREFERRED_CLOSE_DELIMITER: &'static str = Self::PREFERRED_CLOSE_DELIMITER

source§

const PREFERRED_OPEN_DELIMITER: &'static str = Self::PREFERRED_OPEN_DELIMITER