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§
Sourceconst PREFERRED_OPEN_DELIMITER: &'static str = " = "
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.
Sourceconst PREFERRED_CLOSE_DELIMITER: &'static str = ""
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§
Sourcefn parse_named(
name: &'static str,
input: ParseStream<'_>,
) -> Result<Option<Named<SpannedValue<Self::Partial>>>>
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.