Impl ToF64 for f32 and f64

This commit is contained in:
LeopoldArkham 2022-11-16 11:39:48 +01:00
parent 09628d8492
commit 759ac54577
2 changed files with 5 additions and 1 deletions

View file

@ -12,7 +12,7 @@ macro_rules! impl_to_f64 {
)*)
}
impl_to_f64!(for usize u8 u16 u32 u64 isize i8 i16 i32 i64);
impl_to_f64!(for usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64);
pub trait Unsigned {}

View file

@ -13,6 +13,10 @@ fn test_sizes() {
assert_eq!(format_size(1024u32, BINARY), "1 KiB");
assert_eq!(format_size(1024u32, WINDOWS), "1 kB");
assert_eq!(format_size_i(1000f32, DECIMAL), "1 kB");
assert_eq!(format_size_i(1000f64, DECIMAL), "1 kB");
let custom_options = FormatSizeOptions::from(DECIMAL).space_after_value(false);
assert_eq!(format_size(1000u32, custom_options), "1kB");