Parsing a char to u32

char::to_digit(radix) does that. radix denotes the “base”, i.e. 10 for the decimal system, 16 for hex, etc.:

let a = "29";
for c in a.chars() {
    println!("{:?}", c.to_digit(10));
}

It returns an Option, so you need to unwrap() it, or better: expect("that's no number!"). You can read more about proper error handling in the appropriate chapter of the Rust book.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)