3 #![allow(dead_code, unused_variables)]
4 #![warn(clippy::string_lit_as_bytes)]
6 fn str_lit_as_bytes() {
7 let bs = b"hello there";
9 let bs = br###"raw string with 3# plus " ""###;
11 let bs = b"lit to string".to_vec();
12 let bs = b"lit to owned".to_vec();
14 // no warning, because these cannot be written as byte string literals:
15 let ubs = "☃".as_bytes();
16 let ubs = "hello there! this is a very long string".as_bytes();
18 let ubs = "☃".to_string().into_bytes();
19 let ubs = "this is also too long and shouldn't be fixed".to_string().into_bytes();
21 let strify = stringify!(foobar).as_bytes();
23 let current_version = env!("CARGO_PKG_VERSION").as_bytes();
25 let includestr = include_bytes!("string_lit_as_bytes.rs");
27 let _ = b"string with newline\t\n";