pub trait ToModuleName {
type Output;
// Required method
fn to_module_name(&self) -> Self::Output;
}Expand description
Types convertible to the letter casing corresponding to names of modules.
Required Associated Types§
Required Methods§
Sourcefn to_module_name(&self) -> Self::Output
fn to_module_name(&self) -> Self::Output
Converts self to the letter casing of
module names (snake_case).
Adheres to the general conversion rules.
§Examples
Usage with syn::Ident:
let enum_name = Ident::new("DinosaurSpecies", Span::call_site());
let module_name = enum_name.to_module_name();
assert_eq!(module_name, "dinosaur_species");Usage with strings:
assert_eq!("T_REX".to_module_name(), "t_rex");
assert_eq!(String::from("AlexAndDerMurder").to_module_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 ToModuleName for Ident
Available on crate feature syn only.
impl ToModuleName for Ident
Available on crate feature
syn only.