Skip to content

Commit aa345a8

Browse files
committed
chomp_int is technically still used
1 parent 93f7b04 commit aa345a8

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/parse.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,18 @@ fn rm_enc_prefix<'a>(s: &'a str, enc: &Encoding) -> Option<&'a str> {
7575
rm_prefix(s, code)
7676
}
7777

78-
fn rm_int_prefix(s: &str, other: u32) -> Option<&str> {
78+
fn chomp_int(s: &str) -> Option<(u32, &str)> {
79+
// Chomp until we hit a non-digit
7980
let (num, t) = match s.find(|c: char| !c.is_digit(10)) {
8081
Some(i) => s.split_at(i),
8182
None => (s, ""),
8283
};
83-
num.parse().ok()
84-
.and_then(|n| if other == n { Some(t) } else { None })
84+
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 })
8590
}
8691

8792
fn rm_prefix<'a>(s: &'a str, other: &str) -> Option<&'a str> {

0 commit comments

Comments
 (0)