mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-01 00:49:30 +00:00
88c4a22480
This patch adds a new lint that checks for potentially harder to read byte char slices: `&[b'a', b'b']` and suggests to replace them with the easier to read `b"ab"` form. Signed-Off-By: Marcel Müller <m.mueller@ifm.com> Co-authored-by: Matthias Beyer <matthias.beyer@ifm.com> Use iterator to skip validation Signed-off-by: Marcel Müller <m.mueller@ifm.com> Suggested-by: Alex Macleod <alex@macleod.io> Convert quote escapes to proper form Signed-off-by: Marcel Müller <m.mueller@ifm.com> Add more convertable test cases Signed-off-by: Marcel Müller <m.mueller@ifm.com>
13 lines
283 B
Rust
13 lines
283 B
Rust
#![allow(unused)]
|
|
#![warn(clippy::byte_char_slices)]
|
|
|
|
fn main() {
|
|
let bad = b"abc";
|
|
let quotes = b"\"Hi";
|
|
let quotes = b"'Sup";
|
|
let escapes = b"\x42Esc";
|
|
|
|
let good = &[b'a', 0x42];
|
|
let good = [b'a', b'a'];
|
|
let good: u8 = [b'a', b'c'].into_iter().sum();
|
|
}
|