File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,8 @@ fn get_repo_size(repo: &Repository) -> (String, u64) {
4040
4141fn bytes_to_human_readable ( bytes : u64 ) -> String {
4242 let byte = Byte :: from_u64 ( bytes) ;
43- byte. get_appropriate_unit ( UnitType :: Binary ) . to_string ( )
43+ let adjusted_byte_based = byte. get_appropriate_unit ( UnitType :: Binary ) ;
44+ format ! ( "{adjusted_byte_based:#.2}" )
4445}
4546
4647impl std:: fmt:: Display for SizeInfo {
@@ -115,7 +116,8 @@ mod test {
115116 case( 1024 , "1 KiB" ) ,
116117 case( 2048 , "2 KiB" ) ,
117118 case( 1048576 , "1 MiB" ) ,
118- case( 1099511627776 , "1 TiB" )
119+ case( 1099511627776 , "1 TiB" ) ,
120+ case( 2577152 , "2.46 MiB" )
119121 ) ]
120122 fn test_bytes_to_human_readable ( #[ case] input : u64 , #[ case] expected : & str ) {
121123 assert_eq ! ( bytes_to_human_readable( input) , expected) ;
You can’t perform that action at this time.
0 commit comments