For instance:
let n = "1010";
let m: u32 = ?
It can be done by adding each digit multiplied by the right power of two but is there another, simpler, built-in way ?
You are looking for from_str_radix, available to all
core integer types.
let n = "1010";
let m = u32::from_str_radix(n, 2)?;
assert_eq!(m, 10);