Function translate_slice

Source
pub fn translate_slice(bytes: &mut [u8])
Expand description

Translates a slice in place.

This works the same as the JsonCompatRead struct but instead converts a slice in place. This is useful when working with JSON in slices.

Examples found in repository?
examples/cli.rs (line 11)
6fn main() {
7    let mut buffer = vec![];
8    io::stdin().read_to_end(&mut buffer).unwrap();
9    let old_buffer = buffer.clone();
10
11    translate_slice(&mut buffer[..]);
12    assert_eq!(str::from_utf8(&buffer[..]), str::from_utf8(&old_buffer[..]));
13}