use regex::Regex;
fn strip_suffix_digits(s: &str) -> &str {
let re = Regex::new(r"_\d+$").unwrap();
re.replace(s, "").as_ref()
}
As someone who does not program in Rust I find that quite readable, though I haven’t run it and can’t comment on how it compares outside of LOC. It does depend on the regex crate though.