Re:What Is Rust's Unsafe? (2019)
by aliceryhl on Monday April 11, 2022 @05:22AM
(#30986422)
It is perfectly reasonable that `from_utf8_unchecked` is unsafe because the sequence of operations `from_utf8_unchecked(array).chars().next()` will call [1] and can trigger memory unsafety with the `unwrap_unchecked` call if the array is not valid utf-8. This means that at least one of the three functions must be marked unsafe.
[1] https://github.com/rust-lang/rust/blob/027a232755fa9728e9699...