Skip to content

Instantly share code, notes, and snippets.

@Every2
Last active October 11, 2024 22:47
Show Gist options
  • Save Every2/fc137b0aca9d7dc40e85078fe295c927 to your computer and use it in GitHub Desktop.
Save Every2/fc137b0aca9d7dc40e85078fe295c927 to your computer and use it in GitHub Desktop.
to_int do Zan
//Não cobre os casos negativos
fn to_int(str: &str) -> u32 {
let mut n = 0;
for i in str.chars() {
n *= 10;
n += i as u32 - 0x30;
}
n
}
fn main() {
println!("{}", to_int("42"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment