Caseidae
Convenient crate converting conventional casings of Rust identifiers, conveying correct context.
While there are several crates providing casing manipulation functionality,
Caseidae is specifically designed for converting identifiers. It has built-in
support for syn::Ident,
handles lifetime annotations, and preserves prefixes like raw identifiers (r#)
and underscores.
Additionally, general casing conversions don't convey the same meaning. For
instance, instead of exposing a function named to_snake_case, this crate
provides the same conversion under functions called
to_variable_name,
to_field_name,
to_function_name
and so on. A reader of the code doesn't have to think about what the casing
looks like, or why it was chosen in the particular case (pun accidental) – the
intent is clear.
Example
Imagine we are writing a wild macro that generates functions based on traits, such that
- the function name is the trait name,
- the parameters are the trait's associated constants,
- the generic type parameters are the trait's functions,
- the lifetime parameters are the trait's generic parameters.
For instance, turning
into
Type, __HiddenSecret>
Then our code might look like this:
use ;
use ;
use quote;
use Ident;
You can test this in examples/macro.rs.