Skip to main content

Module case

Module case 

Source
Expand description

Case conversion utilities. Case conversion functions and macros.

zyn ships its own case conversion — no dependency on heck.

§Functions

use zyn_core::case;

assert_eq!(case::to_snake("HelloWorld"),   "hello_world");
assert_eq!(case::to_pascal("hello_world"), "HelloWorld");
assert_eq!(case::to_camel("hello_world"),  "helloWorld");
assert_eq!(case::to_screaming("fooBar"),   "FOO_BAR");
assert_eq!(case::to_kebab("FooBar"),       "foo-bar");

§Macros

// String form
let s: String = zyn_core::snake!("HelloWorld");
// → "hello_world"

// Ident form (preserves span)
let id: syn::Ident = zyn_core::pascal!(my_ident => ident);
// my_ident = `foo_bar` → `FooBar`

Functions§

to_camel
Converts a string to camelCase.
to_kebab
Converts a string to kebab-case.
to_pascal
Converts a string to PascalCase.
to_screaming
Converts a string to SCREAMING_SNAKE_CASE.
to_snake
Converts a string to snake_case.