rust


How to parse i64 from a string? [duplicate]


This question already has an answer here:
Convert a String to int in Rust?
4 answers
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 FromStr trait is now in str::str::FromStr. Also, from_str is no longer in the prelude. The preferred way to convert strings to integers now is the recently added std::str::StrExt::parse.
fn main() {
let i = "123".parse::<i64>();
println!("{:?}", i);
}
prints
Some(123)
Demo

Related Links

Why am I getting a “value must be known” error on tuple in a for-loop?
Waiting for a result mapped future
Use different impl when type parameters are the same
Weird characters when using cursive SelectView
How to return a instance of a struct that uses a locally declared variable [duplicate]
Cannot infer an appropriate lifetime when calling a mutable method with references passed as closure arguments
How to access the element at variable index of a tuple?
Iron::new()::http() intercepts stdin
Join futures with limited concurrency
How to get Racer working with Atom?
How do I compile the raw-cpuid crate in rust?
Anonymous enum in Rust
Lifetime of references in closures
Why can't the Option.expect() message be downcast as a &'static str when a panic is handled with catch_unwind?
Why does the Rust documentation say that sharing a reference to a vector would create an invalid vector even though the vector is on the heap?
Polymorphism in Rust and trait references (trait objects?)

Categories

HOME
hpoo
visual-studio
plesk
xcode8.1
d3.js
couchdb
bots
message-queue
ag-grid
ui-automation
scheduler
specifications
driver
solution
xamarin-zebble
watch-os-3
clish
orc
reselect
user-defined-types
salt-cloud
http-authentication
bazaar
anova
android-permissions
channel
hevc
android-cardview
history.js
dnsmasq
guice
quick-nimble
plantuml
overwrite
payeezy
python-jira
resampling
distributed-caching
fiware-wirecloud
julius-speech
morphline
transparency
zend-form
autorelease
webalizer
embedded-v8
google-news
pen
patternlab.io
mpmovieplayercontroller
boost-compute
google-identity-toolkit
msg
mathjs
openquery
bilinear-interpolation
visual-studio-monaco
android-4.2-jelly-bean
wikimedia-commons
odesk
mousehover
asp.net-web-api-helppages
org-babel
explain
sablecc
sql-processor
multivariate-testing
igor
spring-social-linkedin
lsa
discovery
jquery-transit
lru
indesign-server
spiral
cmath
ip-geolocation
nsmutablestring
instance-variables
border-box
viewpagerindicator
struts2-s2hibernate
dropshadow
netstream
will-paginate
fragment-identifier
upshot
django-pagination
pyjamas
chunking
multiple-users
tabbarcontroller
rational-unified-process
.net-client-profile

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App