snippetrustMajor
How to concatenate a char onto a string in Rust?
Viewed 0 times
howontostringrustcharconcatenate
Problem
I have tried using the
to_string method on the char but this returns a &str when I need a String.Solution
Using
String::push method is the easiest method:let mut a_string = String::from("Hello World");
a_string.push('!');Code Snippets
let mut a_string = String::from("Hello World");
a_string.push('!');Context
Stack Overflow Q#37889337, score: 84
Revisions (0)
No revisions yet.