Answers for "rust turn to string"

0

convert number to string rust

let x: u32 = 10;
let s: String = x.to_string();
println!("{}", s);
Posted by: Guest on October-11-2020
-1

string to str rust

// You cannot convert a String to a str in rust since it is not static
// You can convert a slice of a string to a &str as so:
let string_slice: &str = &s[..];
Posted by: Guest on April-06-2021

Browse Popular Code Answers by Language