generated from PlexSheep/rs-base
fix: use a dependency to split the int instead of a builtin function #8
cargo devel CI / cargo CI (push) Failing after 1m13s
Details
cargo devel CI / cargo CI (push) Failing after 1m13s
Details
This commit is contained in:
parent
66144dcb3c
commit
24bf6cd97e
|
@ -17,4 +17,5 @@ anyhow = "1.0.83"
|
||||||
clap = { version = "4.5.4", features = ["derive"] }
|
clap = { version = "4.5.4", features = ["derive"] }
|
||||||
clap-num = "1.1.1"
|
clap-num = "1.1.1"
|
||||||
fast32 = "1.0.2"
|
fast32 = "1.0.2"
|
||||||
|
libpt = { version = "0.5.0", features = ["bintols"]}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use libpt::bintols::split;
|
||||||
|
|
||||||
pub type Num = u128;
|
pub type Num = u128;
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
|
@ -47,21 +49,9 @@ impl Format {
|
||||||
Format::Dec => {
|
Format::Dec => {
|
||||||
buf += &format!("{num}");
|
buf += &format!("{num}");
|
||||||
}
|
}
|
||||||
Format::Base64 => buf += &fast32::base64::RFC4648.encode(&u128_to_u8_slice(num)),
|
Format::Base64 => buf += &fast32::base64::RFC4648.encode(&split::unsigned_to_vec(num)),
|
||||||
Format::Base32 => buf += &fast32::base32::RFC4648.encode(&u128_to_u8_slice(num)),
|
Format::Base32 => buf += &fast32::base32::RFC4648.encode(&split::unsigned_to_vec(num)),
|
||||||
}
|
}
|
||||||
buf
|
buf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn u128_to_u8_slice(mut num: u128) -> Vec<u8> {
|
|
||||||
if num == 0 {
|
|
||||||
return vec![0];
|
|
||||||
}
|
|
||||||
let mut buf: Vec<u8> = Vec::new();
|
|
||||||
while num > 0 {
|
|
||||||
buf.push(num as u8);
|
|
||||||
num >>= 8;
|
|
||||||
}
|
|
||||||
buf
|
|
||||||
}
|
|
||||||
|
|
Reference in New Issue