Function roe::to_ascii_lowercase
source · pub fn to_ascii_lowercase<T: AsRef<[u8]>>(slice: T) -> Vec<u8>
Available on crate feature
alloc
only.Expand description
Returns a vector containing a copy of the given slice where each byte is mapped to its ASCII lower case equivalent.
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
and
Symbol#downcase
for ASCII strings in Ruby.
To lowercase the value in-place, use make_ascii_lowercase
. This function
is analogous to <[u8]>::to_ascii_lowercase
.
Examples
assert_eq!(to_ascii_lowercase("ABCxyz"), &b"abcxyz"[..]);
assert_eq!(to_ascii_lowercase("1234%&*"), &b"1234%&*"[..]);