rust/tests/ui/single_char_add_str.fixed

56 lines
1.1 KiB
Rust

#![warn(clippy::single_char_add_str)]
#![allow(clippy::needless_raw_strings, clippy::needless_raw_string_hashes)]
macro_rules! get_string {
() => {
String::from("Hello world!")
};
}
fn main() {
// `push_str` tests
let mut string = String::new();
string.push('R');
string.push('\'');
string.push('u');
string.push_str("st");
string.push_str("");
string.push('\x52');
string.push('\u{0052}');
string.push('a');
let c_ref = &'a';
string.push(*c_ref);
let c = 'a';
string.push(c);
string.push('a');
get_string!().push('ö');
// `insert_str` tests
let mut string = String::new();
string.insert(0, 'R');
string.insert(1, '\'');
string.insert(0, 'u');
string.insert_str(2, "st");
string.insert_str(0, "");
string.insert(0, '\x52');
string.insert(0, '\u{0052}');
let x: usize = 2;
string.insert(x, 'a');
const Y: usize = 1;
string.insert(Y, 'a');
string.insert(Y, '"');
string.insert(Y, '\'');
string.insert(0, *c_ref);
string.insert(0, c);
string.insert(0, 'a');
get_string!().insert(1, '?');
}