Function stoi

Source
pub fn stoi<T: FromStr>(b: &[u8]) -> Result<T>
where <T as FromStr>::Err: Error + Sync + Send + 'static,
Expand description

Parse byte slice into an integer. The opposite of itos. On error (such as Utf8Error or ParseIntError) this does return Err() implicitly.

Use return type-inference to specify the integer type, e.g: let val: u16 = stoi(&s);