Skip to main content

title_case

Function title_case 

Source
pub fn title_case(s: &str) -> String
Expand description

Titlecases s, treating each maximal run of cased characters as a word.

Follows Python’s str.title() word-boundary rules: the first character of each word uses its Unicode titlecase mapping, and the rest are lowercased. Unlike Python, a word-final Σ lowercases to σ, not ς.

§Examples

use nautilus_core::string::conversions::title_case;

assert_eq!(title_case("example"), "Example");
assert_eq!(title_case("hello_world"), "Hello_World");
assert_eq!(title_case("hello world"), "Hello World");
assert_eq!(title_case(""), "");