Function roe::make_ascii_uppercase

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

Converts the given slice to its ASCII upper 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#upcase! for ASCII strings in Ruby.

To return a new uppercased value without modifying the existing one, use to_ascii_uppercase. This function is analogous to <[u8]>::make_ascii_uppercase.

Examples

let mut buf = *b"ABCxyz";
make_ascii_uppercase(&mut buf);
assert_eq!(buf, *b"ABCXYZ");

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