string_morph 0.1.0

string_morph is a library of string case transformations with an emphasis on accuracy and performance. The case conversions are available as functions as well as traits on String types.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
pub fn to_upper_first(input: &str) -> String {
    let mut c = input.chars();

    match c.next() {
        None => String::new(),
        Some(x) => x.to_uppercase().collect::<String>() + c.as_str()
    }
}

pub fn to_lower_first(input: &str) -> String {
    let mut c = input.chars();

    match c.next() {
        None => String::new(),
        Some(x) => x.to_lowercase().collect::<String>() + c.as_str()
    }
}