How to convert char to string?
Use char::to_string
, which is from the ToString
trait:
fn main() {
let string = 'c'.to_string();
// or
println!("{}", 'c');
}
You can now use c.to_string()
, where c
is your variable of type char
.