mirror of
https://github.com/HigherOrderCO/Bend.git
synced 2024-08-16 15:20:40 +03:00
[sc-119] Remove byte-unit dependency
This commit is contained in:
parent
cf841094cc
commit
b1488439cf
37
Cargo.lock
generated
37
Cargo.lock
generated
@ -131,16 +131,6 @@ version = "2.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
|
||||
|
||||
[[package]]
|
||||
name = "byte-unit"
|
||||
version = "4.0.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da78b32057b8fdfc352504708feeba7216dcd65a2c9ab02978cbd288d1279b6c"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"utf8-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.83"
|
||||
@ -309,7 +299,6 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bimap",
|
||||
"byte-unit",
|
||||
"chumsky",
|
||||
"clap",
|
||||
"derive_more",
|
||||
@ -568,26 +557,6 @@ version = "1.0.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.189"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.189"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.38",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shrinkwraprs"
|
||||
version = "0.3.0"
|
||||
@ -741,12 +710,6 @@ version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
|
||||
|
||||
[[package]]
|
||||
name = "utf8-width"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5190c9442dcdaf0ddd50f37420417d219ae5261bbf5db120d0f9bab996c9cba1"
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
version = "0.2.1"
|
||||
|
@ -15,12 +15,11 @@ lto = true
|
||||
|
||||
[features]
|
||||
default = ["cli"]
|
||||
cli = ["dep:clap", "dep:byte-unit"]
|
||||
cli = ["dep:clap"]
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.72"
|
||||
bimap = "0.6.3"
|
||||
byte-unit = { version = "4.0.19", optional = true }
|
||||
chumsky = "= 1.0.0-alpha.4"
|
||||
clap = { version = "4.4.1", features = ["derive"], optional = true }
|
||||
derive_more = "0.99.17"
|
||||
|
11
src/main.rs
11
src/main.rs
@ -30,8 +30,15 @@ enum Mode {
|
||||
}
|
||||
|
||||
fn mem_parser(arg: &str) -> anyhow::Result<usize> {
|
||||
let bytes = byte_unit::Byte::from_str(arg)?;
|
||||
Ok(bytes.get_bytes() as usize)
|
||||
let (base, mult) = match arg.to_lowercase().chars().last() {
|
||||
None => return Err(anyhow::anyhow!("Mem size argument is empty")),
|
||||
Some('k') => (&arg[0 .. arg.len() - 1], 1 << 10),
|
||||
Some('m') => (&arg[0 .. arg.len() - 1], 1 << 20),
|
||||
Some('g') => (&arg[0 .. arg.len() - 1], 1 << 30),
|
||||
Some(_) => (arg, 1),
|
||||
};
|
||||
let base = base.parse::<usize>()?;
|
||||
Ok(base * mult)
|
||||
}
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
|
Loading…
Reference in New Issue
Block a user