diff options
Diffstat (limited to '')
-rw-r--r-- | src/parse.rs | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/parse.rs b/src/parse.rs index edfd9c5..c5521d6 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -1,10 +1,10 @@ use std::str::FromStr; -use crate::{error::PissError, PissAmount}; +use crate::{PissError, PissAmount}; impl<T> From<T> for PissAmount where T: Into<u128> { - fn from(num: T) -> PissAmount { - PissAmount { + fn from(num: T) -> Self { + Self { to_piss: num.into() } } @@ -23,15 +23,15 @@ fn parse_suffix(s: &str) -> Result<u128, PissError> { "r" | "rb" => 1_000_000_000_000_000_000_000_000_000, "q" | "qb" => 1_000_000_000_000_000_000_000_000_000_000, "ki" | "kib" => 0x400, - "mi" | "mib" => 0x100000, - "gi" | "gib" => 0x40000000, - "ti" | "tib" => 0x10000000000, - "pi" | "pib" => 0x4000000000000, - "ei" | "eib" => 0x1000000000000000, - "xi" | "xib" => 0x400000000000000000, - "yi" | "yib" => 0x100000000000000000000, - "ri" | "rib" => 0x40000000000000000000000, - "qi" | "qib" => 0x10000000000000000000000000, + "mi" | "mib" => 0x0010_0000, + "gi" | "gib" => 0x4000_0000, + "ti" | "tib" => 0x0100_0000_0000, + "pi" | "pib" => 0x0004_0000_0000_0000, + "ei" | "eib" => 0x1000_0000_0000_0000, + "xi" | "xib" => 0x0040_0000_0000_0000_0000, + "yi" | "yib" => 0x0001_0000_0000_0000_0000_0000, + "ri" | "rib" => 0x0400_0000_0000_0000_0000_0000, + "qi" | "qib" => 0x0010_0000_0000_0000_0000_0000_0000, "" | "b" => 1, // uwu _ => return Err(PissError::InvalidSuffix(s.into())) // such nepal }) @@ -40,7 +40,7 @@ fn parse_suffix(s: &str) -> Result<u128, PissError> { fn parse_file_size(s: &str) -> Result<PissAmount, PissError> { let mut end = 0; for (i, c) in s.char_indices() { - if c.is_digit(10) || c == '.' { continue; } + if c.is_ascii_digit() || c == '.' { continue; } end = i; break; } |