Skip to content

capitalize

Uppercases the first character of s and leaves the rest untouched.

Unicode-aware: a character whose uppercase form is several characters (ß -> SS) is expanded accordingly.

use helpers4::string::capitalize;

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 capitalize(s: &str) -> String
ParameterTypeDescription
s&strThe text to capitalize.

String

use helpers4::string::capitalize;

assert_eq!(capitalize("hello world"), "Hello world");
assert_eq!(capitalize(""), "");

src/string/capitalize.rs