I tried converting u32 to str but i cant find a way to do it then i tried to convert u32 to &String then &String to &str but that doesnt work too.
&String and &str are both borrowed values, so there needs to be an owned value they borrow from. That would look something like this:
let owned = 3.to_string(); let borrowed = &owned; // use `borrowed` in the rest of your program
Most of the time &String to &str is done automatically when you call a function or print it out, you normally don't need an explicit conversion. If you do, you can use
See https://doc.rust-lang.org/book/ch04-00-understanding-ownership.html for more details on ownership and
I suggest reading through the following article, my favourite one about
String in rust:
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.