let my_u8: u8 = "42".parse::<u8>().unwrap(); let my_u32: u32 = "42".parse::<u32>().unwrap(); // or, to be safe, match the `Err` match "foobar".parse::<i32>() { Ok(n) => do_something_with(n), Err(e) => weep_and_moan(), }