wonfy-tools 0.1.3

Collection of tools for personal use, provides library and CLI.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
pub fn parse_first_number(s: &str) -> Option<u64> {
    let mut num = String::new();
    let mut found = false;

    for c in s.chars() {
        if c.is_ascii_digit() {
            num.push(c);
            found = true;
        } else if found {
            break;
        }
    }

    match found {
        true => num.parse().ok(),
        false => None,
    }
}