Function macro_tools::is_standard
source · pub fn is_standard<'a>(attr_name: &'a str) -> bool
Expand description
Checks if the given attribute name is a standard Rust attribute.
Standard Rust attributes are those which are recognized and processed directly by the Rust compiler. They influence various aspects of compilation, including but not limited to conditional compilation, optimization hints, code visibility, and procedural macro behavior.
This function is useful when developing tools that need to interact with or understand the significance of specific attributes in Rust source code, such as linters, code analyzers, or procedural macros.
This function does not cover all possible attributes but includes many of the common ones that are relevant to most Rust projects. Developers are encouraged to update this function as needed to suit more specialized needs, especially when dealing with nightly-only compiler attributes or deprecated ones.
§Parameters
attr_name
: A string slice that holds the name of the attribute to check.
§Returns
Returns true
if attr_name
is a recognized standard Rust attribute. Otherwise,
returns false
.
§Examples
Standard attributes:
assert_eq!( macro_tools::attr::is_standard( "cfg" ), true );
assert_eq!( macro_tools::attr::is_standard( "inline" ), true );
assert_eq!( macro_tools::attr::is_standard( "derive" ), true );
Non-standard or custom attributes:
assert_eq!( macro_tools::attr::is_standard( "custom_attr" ), false );
assert_eq!( macro_tools::attr::is_standard( "my_attribute" ), false );