How to concatenate a char onto a string in Rust?
You can also use format!
:
fn main() {
let s = String::from("March");
// example 1
let s1 = format!("{}!", s);
// example 2
let s2 = format!("{}{}", s, '!');
// print
println!("{} {}", s1, s2);
}
https://doc.rust-lang.org/std/macro.format.html
Using String::push
method is the easiest method:
let mut a_string = String::from("Hello World");
a_string.push('!');