Apparently, something has changed and thus I can't parse i64 from string:
use std::from_str::FromStr;
let tree1: BTreeMap<String, String> = //....
let my_i64: i64 = from_str(tree1.get("key1").unwrap().as_slice()).unwrap();
Error:
16:27 error: unresolved import `std::from_str::FromStr`. Could not find `from_str` in `std`
$ rustc -V
rustc 1.0.0-nightly (4be79d6ac 2015-01-23 16:08:14 +0000)
Your import fails because the FromStr
trait is now std::str::FromStr
. Also, from_str
is no longer in the prelude
. The preferred way to convert strings to integers is str::parse
fn main() {
let i = "123".parse::<i64>();
println!("{:?}", i);
}
prints
Ok(123)
Demo
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