2020-09-13 13:00:45 +02:00
|
|
|
// run-rustfix
|
2020-10-08 00:03:26 +02:00
|
|
|
#![warn(clippy::single_char_add_str)]
|
2020-09-13 13:00:45 +02:00
|
|
|
|
2020-09-14 15:31:04 +02:00
|
|
|
macro_rules! get_string {
|
|
|
|
() => {
|
|
|
|
String::from("Hello world!")
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-09-13 13:00:45 +02:00
|
|
|
fn main() {
|
2020-10-08 00:03:26 +02:00
|
|
|
// `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');
|
|
|
|
|
|
|
|
get_string!().push('ö');
|
|
|
|
|
|
|
|
// `insert_str` tests
|
|
|
|
|
2020-09-13 13:00:45 +02:00
|
|
|
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');
|
2020-10-30 23:47:22 +01:00
|
|
|
string.insert(Y, '"');
|
|
|
|
string.insert(Y, '\'');
|
2020-09-14 15:31:04 +02:00
|
|
|
|
|
|
|
get_string!().insert(1, '?');
|
2020-09-13 13:00:45 +02:00
|
|
|
}
|