Skip to main content

ToMacroName

Trait ToMacroName 

Source
pub trait ToMacroName {
    type Output;

    // Required method
    fn to_macro_name(&self) -> Self::Output;
}
Expand description

Types convertible to the letter casing corresponding to names of macros.

Required Associated Types§

Source

type Output

The resulting type, coming out of the conversion.

Required Methods§

Source

fn to_macro_name(&self) -> Self::Output

Converts self to the letter casing of macro names (snake_case). Adheres to the general conversion rules.

§Examples

Usage with syn::Ident:

let trait_name = Ident::new("PartialEq", Span::call_site());
let macro_name = trait_name.to_macro_name();
assert_eq!(macro_name, "partial_eq");

Usage with strings:

assert_eq!("HTTPS_HRYZIKO_DEV".to_macro_name(), "https_hryziko_dev");
assert_eq!(String::from("AlexAndDerMurder").to_macro_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 ToMacroName for Ident

Available on crate feature syn only.
Source§

impl ToMacroName for str

Implementors§