Programming-Idioms

History of Idiom 22 > diff from v34 to v35

Edit summary for version 35 :
[Rust] Comment conciseness.

Version 34

2016-01-08, 13:51:09

Version 35

2016-01-08, 13:52:04

Idiom #22 Convert string to integer

Extract integer value i from its string representation s (in radix 10)

Idiom #22 Convert string to integer

Extract integer value i from its string representation s (in radix 10)

Code
let i = s.parse::<i32>().unwrap();
Code
let i = s.parse::<i32>().unwrap();
Comments bubble
This panics if s is not a valid number.
s is parsed to 32-bits signed integer here, but you can change number type to whatever you want.
Comments bubble
This panics if s is not a valid number.
s is parsed to 32-bits signed integer here (change number type if needed).