Skip to main content

parse_attribute

Function parse_attribute 

Source
pub fn parse_attribute(text: &str) -> Result<Attribute>
Expand description

Parse a single standalone #[...] outer attribute from text.

syn::Attribute has no direct syn::parse::Parse impl of its own (an attribute is only ever parsed as part of something else) — this is the Attribute::parse_outer-based equivalent of syn::parse_str for exactly this one node type, since generating one from a formatted string (format!("#[{name}({args})]")) is how every caller in this workspace builds a new attribute to insert.

§Errors

Returns Err if text isn’t a single valid #[...] attribute.