We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 93f7b04 commit aa345a8Copy full SHA for aa345a8
src/parse.rs
@@ -75,13 +75,18 @@ fn rm_enc_prefix<'a>(s: &'a str, enc: &Encoding) -> Option<&'a str> {
75
rm_prefix(s, code)
76
}
77
78
-fn rm_int_prefix(s: &str, other: u32) -> Option<&str> {
+fn chomp_int(s: &str) -> Option<(u32, &str)> {
79
+ // Chomp until we hit a non-digit
80
let (num, t) = match s.find(|c: char| !c.is_digit(10)) {
81
Some(i) => s.split_at(i),
82
None => (s, ""),
83
};
- num.parse().ok()
84
- .and_then(|n| if other == n { Some(t) } else { None })
+ num.parse().map(|n| (n, t)).ok()
85
+}
86
+
87
+fn rm_int_prefix(s: &str, other: u32) -> Option<&str> {
88
+ chomp_int(s)
89
+ .and_then(|(n, t)| if other == n { Some(t) } else { None })
90
91
92
fn rm_prefix<'a>(s: &'a str, other: &str) -> Option<&'a str> {
0 commit comments