RS.CLIPPY.STRING_FROM_UTF8_AS_BYTES
Casting string slices to byte slices and back
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: string_from_utf8_as_bytes. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Check if the string is transformed to byte array and casted back to string.
Why is this bad?
It's unnecessary, the string can be used directly.
Example
std::str::from_utf8(&"Hello World!".as_bytes()[6..11]).unwrap();
Use instead:
&"Hello World!"[6..11];