Skip to content

constant_case

Converts s to CONSTANT_CASE (also known as SCREAMING_SNAKE_CASE).

Splits words the same way as camel_case.

use helpers4::string::constant_case;

Cargo feature string (enabled by default). To compile only this module:

cargo add helpers4 --no-default-features --features string

or in Cargo.toml:

[dependencies]
helpers4 = { version = "0.0.5", default-features = false, features = ["string"] }
pub fn constant_case(s: &str) -> String
ParameterTypeDescription
s&strThe text to convert.

String

use helpers4::string::constant_case;

assert_eq!(constant_case("helloWorld"), "HELLO_WORLD");
assert_eq!(constant_case("max retries"), "MAX_RETRIES");
assert_eq!(constant_case(""), "");

src/string/constant_case.rs