Skip to content

Commit 254a478

Browse files
committed
Improve check_throttling_error() logic
1 parent 09a7b25 commit 254a478

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

src/utils.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ pub fn check_throttling_error(string: &str) -> Option<u64> {
66
static RE: LazyLock<Regex> = LazyLock::new(|| {
77
Regex::new(r"Guest logins are restricted to one per IP address per (\d+) seconds").unwrap()
88
});
9-
if let Some(captures) = RE.captures(string) {
10-
captures.get(1).unwrap().as_str().parse::<u64>().ok()
11-
} else {
12-
None
13-
}
9+
let captures = RE.captures(string)?;
10+
let duration_capture = captures.get(1)?;
11+
duration_capture.as_str().parse::<u64>().ok()
1412
}
1513

1614
/// Parse host from plain domain name or URL.

0 commit comments

Comments
 (0)