views and bug fixes
This commit is contained in:
@@ -1,3 +1,21 @@
|
||||
pub mod time;
|
||||
pub mod flaresolverr;
|
||||
pub mod cache;
|
||||
pub mod cache;
|
||||
|
||||
pub fn parse_abbreviated_number(s: &str) -> Option<u32> {
|
||||
let s = s.trim();
|
||||
if s.is_empty() {
|
||||
return None;
|
||||
}
|
||||
let (num_part, suffix) = s
|
||||
.chars()
|
||||
.partition::<String, _>(|c| c.is_ascii_digit() || *c == '.');
|
||||
let multiplier = match suffix.trim().to_ascii_uppercase().as_str() {
|
||||
"K" => 1_000.0,
|
||||
"M" => 1_000_000.0,
|
||||
"B" => 1_000_000_000.0,
|
||||
"" => 1.0,
|
||||
_ => return None,
|
||||
};
|
||||
num_part.parse::<f64>().ok().map(|n| (n * multiplier) as u32)
|
||||
}
|
||||
Reference in New Issue
Block a user