Closed
Description
Playground: https://play.rust-lang.org/?gist=935daee28b05c2afcdf61423fdfb40f8&version=stable
fn parse_bytes(s: &[u8]) {
// do something
}
fn main() {
parse_bytes("hello");
}
This includes the error:
error[E0308]: mismatched types
--> src/main.rs:6:17
|
6 | parse_bytes("hello");
| ^^^^^^^ expected slice, found str
|
= note: expected type `&[u8]`
found type `&'static str`
= help: here are some functions which might fulfill your needs:
- .as_bytes()
Whereas it could be much better suggesting the user to type b"hello"
instead of supplying "hello".as_bytes()
.