Is there a reason why char::is_ascii_digit and char::is_ascii_hexdigit exist, whereas there is no shorthand to check if a character is a valid octal? While it is as simple as matches!(c, '0'..='7'), I would prefer to have the proposed API because:
it is a lot more ergonomic in point-free form, i.e.: my_string.chars().filter(char::is_ascii_octdigit) as compared to my_string.chars().filter(|c| matches!(c, '0'..='7')) or my_string.chars().filter(|c| '0'..='7'.contains(c))
the intent is a lot more obvious
completeness, I just think it fills a gap(?) in the list of char functions
And if the libs API is to be expanded, it should probably now use const generics to be more general eg fn is_digit_const<const BASE: u32>(self) -> bool which could then be invoked in "point-free" form as eg my_string.chars().filter(char::is_digit_const::<8>).
I myself happened to use it earlier today to represent bit lengths, because the second position onward represent the number of bytes and the units represent offset into the final byte.
I would be happy to merge a PR adding this method (as unstable, with a tracking issue). As several people in this thread observed, it does still come up in the context of file modes.