Skip to content

snake_case

Converts s to snake_case.

Splits words the same way as camel_case.

use helpers4::string::snake_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 snake_case(s: &str) -> String
ParameterTypeDescription
s&strThe text to convert.

String

use helpers4::string::snake_case;

assert_eq!(snake_case("helloWorld"), "hello_world");
assert_eq!(snake_case("Hello World"), "hello_world");
assert_eq!(snake_case(""), "");

src/string/snake_case.rs