I am unable to compile code that converts a type from an integer to a string. I'm running an example from the Rust for Rubyists tutorial which has various type conversions such as:
"Fizz".to_str() and num.to_str() (where num is an integer).
I think the majority (if not all) of these to_str() function calls have been deprecated. What is the current way to convert an integer to a string?
The errors I'm getting are:
error: type `&'static str` does not implement any method in scope named `to_str`
error: type `int` does not implement any method in scope named `to_str`
to_string()method but that returnsStringand not a literal string. - user3358302to_str()was a different return value, I'll useto_string()- user3358302&'static str, that is, a string slice with a static lifetime, which is impossible to obtain using dynamically created data. You can only create them using string literals. - Vladimir Matveevto_strconfused me (which as you said, they renamed for clarity) thinking it was returning a string slice instead of aStringobject. - user3358302