Is there a succinct way to convert a char
to a String
in Rust other than:
let mut s = String::new();
s.push('c');
To convert elements of a Vector to Strings in R, use the toString() function. The toString() is an inbuilt R function used to produce a single character string describing an R object.
The toString() and valueOf() methods can both be used to convert a char to a string in Java.
You use the to_string()
method:
'c'.to_string()
Since Rust 1.46, String
implements From<char>
, so you can alternatively use:
String::from('c')
or, with type inference,
'c'.into()
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