Open
Description
Clippy version: clippy 0.0.212 (e3cb40e 2019-06-25)
Clippy suggests using a byte string literal b"string literal"
instead of "string literal".as_bytes()
.
The suggestion does not compile in the following case because the type of byte string literal &[u8; N]
does not implement std::io::Read
.
fn f(_: impl std::io::Read) {
}
fn main() {
f("string literal".as_bytes());
// ^^^^^^^^^^^^^ help: consider using a byte string literal instead: `b"string literal"`
// f(b"string literal"); // does not compile
// ^ the trait `std::io::Read` is not implemented for `&[u8; 14]`
f(&b"string literal"[..]); // compiles
}
Clippy should allow the above case or suggest &b"string literal"[..]
.