2 Checks for transmutes from a `&[u8]` to a `&str`.
5 Not every byte slice is a valid UTF-8 string.
8 - [`from_utf8`] which this lint suggests using is slower than `transmute`
9 as it needs to validate the input.
10 If you are certain that the input is always a valid UTF-8,
11 use [`from_utf8_unchecked`] which is as fast as `transmute`
12 but has a semantically meaningful name.
13 - You might want to handle errors returned from [`from_utf8`] instead of calling `unwrap`.
15 [`from_utf8`]: https://doc.rust-lang.org/std/str/fn.from_utf8.html
16 [`from_utf8_unchecked`]: https://doc.rust-lang.org/std/str/fn.from_utf8_unchecked.html
20 let b: &[u8] = &[1_u8, 2_u8];
22 let _: &str = std::mem::transmute(b); // where b: &[u8]
26 let _ = std::str::from_utf8(b).unwrap();