Function roe::make_ascii_lowercase

source ·
pub fn make_ascii_lowercase<T: AsMut<[u8]>>(slice: &mut T)
Expand description

Converts the given slice to its ASCII lower case equivalent in-place.

ASCII letters ‘A’ to ‘Z’ are mapped to ‘a’ to ‘z’, but non-ASCII letters are unchanged.

This function can be used to implement String#downcase! for ASCII strings in Ruby.

To return a new lowercased value without modifying the existing one, use to_ascii_lowercase. This function is analogous <[u8]>::make_ascii_lowercase.

§Examples

let mut buf = *b"ABCxyz";
make_ascii_lowercase(&mut buf);
assert_eq!(buf, *b"abcxyz");

let mut buf = *b"1234%&*";
make_ascii_lowercase(&mut buf);
assert_eq!(buf, *b"1234%&*");