2023-07-31 16:53:53 -05:00
|
|
|
#![allow(unused, dead_code)]
|
|
|
|
#![warn(clippy::format_collect)]
|
|
|
|
|
|
|
|
fn hex_encode(bytes: &[u8]) -> String {
|
|
|
|
bytes.iter().map(|b| format!("{b:02X}")).collect()
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: use of `format!` to build up a string from an iterator
|
2023-07-31 16:53:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[rustfmt::skip]
|
|
|
|
fn hex_encode_deep(bytes: &[u8]) -> String {
|
|
|
|
bytes.iter().map(|b| {{{{{ format!("{b:02X}") }}}}}).collect()
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: use of `format!` to build up a string from an iterator
|
2023-07-31 16:53:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! fmt {
|
|
|
|
($x:ident) => {
|
|
|
|
format!("{x:02X}", x = $x)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
fn from_macro(bytes: &[u8]) -> String {
|
|
|
|
bytes.iter().map(|x| fmt!(x)).collect()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn with_block() -> String {
|
|
|
|
(1..10)
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: use of `format!` to build up a string from an iterator
|
2023-07-31 16:53:53 -05:00
|
|
|
.map(|s| {
|
|
|
|
let y = 1;
|
|
|
|
format!("{s} {y}")
|
|
|
|
})
|
|
|
|
.collect()
|
|
|
|
}
|
|
|
|
fn main() {}
|