Skip to main content

title_case

Function title_case 

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

Title-cases s by capitalizing the first letter of each alphabetic run.

Mirrors Python’s str.title(): word boundaries fall at any non-alphabetic character, the first letter of each run is uppercased, and the rest are lowercased.

§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(""), "");