Skip to main content

to_ascii_lowercase

Function to_ascii_lowercase 

Source
pub fn to_ascii_lowercase(value: &str) -> Cow<'_, str>
Expand description

Converts ASCII characters in value to lowercase if required; otherwise, returns the original slice.

ยงExamples

Returns the original slice:

let actual = to_ascii_lowercase("hello, world!");
assert!(matches!(actual, Cow::Borrowed("hello, world!")));

Returns a clone converted to lowercase ASCII character.

let actual = to_ascii_lowercase("hello, World!");
assert!(matches!(
    actual,
    Cow::Owned(expected) if expected == "hello, world!"
));