I have tried using the to_string method on the char but this returns a &str when I need a String.
Rust provides multiple ways to concatenate or join Strings, but the easiest of them is by using += operator.
Rust owned String type, the string itself lives on the heap and therefore is mutable and can alter its size and contents.
Using String::push method is the easiest method:
let mut a_string = String::from("Hello World"); a_string.push('!');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With