wonfy_tools/util/string/parsing.rs
1pub fn parse_first_number(s: &str) -> Option<u64> {
2 let mut num = String::new();
3 let mut found = false;
4
5 for c in s.chars() {
6 if c.is_ascii_digit() {
7 num.push(c);
8 found = true;
9 } else if found {
10 break;
11 }
12 }
13
14 match found {
15 true => num.parse().ok(),
16 false => None,
17 }
18}