This commit is contained in:
LeopoldArkham 2022-08-26 22:49:12 +02:00
parent b8464e0177
commit f11da47922
2 changed files with 9 additions and 9 deletions

View file

@ -5,7 +5,7 @@ use crate::options::FormatSizeOptions;
use crate::IFormatter;
pub fn format_size_i(input: impl ToF64, options: impl AsRef<FormatSizeOptions>) -> String {
format!("{}", IFormatter{value: input, options: options})
format!("{}", IFormatter{value: input, options})
}
pub fn format_size(input: impl ToF64 + Unsigned, options: impl AsRef<FormatSizeOptions>) -> String {
@ -13,11 +13,11 @@ pub fn format_size(input: impl ToF64 + Unsigned, options: impl AsRef<FormatSizeO
}
pub fn make_format_i<T: ToF64>(options: impl AsRef<FormatSizeOptions>) -> impl Fn(T) -> String {
return move |val | -> String {
move |val | -> String {
format_size_i(val, &options)
}
}
pub fn make_format<T: ToF64 + Unsigned>(options: impl AsRef<FormatSizeOptions>) -> impl Fn(T) -> String {
return make_format_i(options);
make_format_i(options)
}

View file

@ -21,12 +21,12 @@ extern crate humansize;
use humansize::format_size;
fn main() {
let size = 1000usize;
println!("Size is {}", format_size(size, humansize::DECIMAL));
let size = 1000usize;
println!("Size is {}", format_size(size, humansize::DECIMAL));
println!("Size is {}", format_size(size, humansize::BINARY));
println!("Size is {}", format_size(size, humansize::BINARY));
println!("Size is {}", format_size(size, humansize::CONVENTIONAL));
println!("Size is {}", format_size(size, humansize::CONVENTIONAL));
}
```
@ -65,7 +65,7 @@ pub struct IFormatter<T: ToF64, O: AsRef<FormatSizeOptions>> {
impl<V: ToF64, O: AsRef<FormatSizeOptions>> IFormatter<V, O> {
pub fn new(value: V, options: O) -> Self {
IFormatter{value: value, options: options}
IFormatter{value: value, options}
}
}
@ -129,7 +129,7 @@ pub struct Formatter<T: ToF64 + Unsigned, O: AsRef<FormatSizeOptions>> {
impl<V: ToF64 + Unsigned, O: AsRef<FormatSizeOptions>> Formatter<V, O> {
pub fn new(value: V, options: O) -> Self {
Formatter{value: value, options: options}
Formatter{value, options}
}
}