With a recent nightly, you can do this:
let my_int = from_str::<int>(&*my_string);
What's happening here is that String
can now be dereferenced into a str
. However, the function wants an &str
, so we have to borrow again. For reference, I believe this particular pattern (&*
) is called "cross-borrowing".