pub trait ToStaticName {
type Output;
// Required method
fn to_static_name(&self) -> Self::Output;
}Expand description
Types convertible to the letter casing corresponding to names of static items.
Required Associated Types§
Required Methods§
Sourcefn to_static_name(&self) -> Self::Output
fn to_static_name(&self) -> Self::Output
Converts self to the letter casing of static
item names
(SCREAMING_SNAKE_CASE). Adheres to the general conversion
rules.
§Examples
Usage with syn::Ident:
let struct_name = Ident::new("MemoryLeakedMb", Span::call_site());
let static_name = struct_name.to_static_name();
assert_eq!(static_name, "MEMORY_LEAKED_MB");Usage with strings:
assert_eq!("earth_moon_distance".to_static_name(), "EARTH_MOON_DISTANCE");
assert_eq!(String::from("AlexAndDerMurder").to_static_name(), "ALEX_AND_DER_MURDER");§Panics
Whether this method panics depends on the implementator, see their documentation for that. However, implementations from this crate never panic.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl ToStaticName for Ident
Available on crate feature syn only.
impl ToStaticName for Ident
Available on crate feature
syn only.