-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
df: fix rounding behavior in humanreadable mode #3554
Conversation
@@ -220,56 +208,64 @@ mod tests { | |||
|
|||
use std::env; | |||
|
|||
use crate::blocks::{to_magnitude_and_suffix, BlockSize}; | |||
use crate::blocks::{to_magnitude_and_suffix, BlockSize, SuffixType}; | |||
|
|||
#[test] | |||
fn test_to_magnitude_and_suffix_powers_of_1024() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to admit, it's pretty difficult to follow the logic of HumanReadable
, SizeFormat
, BlockSize
, SuffixType
, and more, but if I'm reading this pull request correctly, we are just decoupling the value of the number (1024, 2048, 4096, etc.) from the decision of what suffix to apply (SuffixType::IEC
, SuffixType:SI
, etc.). So we could now call to_magnitude_and_suffix(1024, SuffixType::SI)
if we wanted to. Is that right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's correct.
Your comment made me rethink the enums you mentioned and I realized that SizeFormat
is not necessary and I turned it into an Option<HumanReadable>
with the latest push. I hope this reduces some of the complexity.
I'm not sure about the |
0265afa
to
e565b52
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes the bug, and removing one of the enums seems like an improvement to me.
This PR makes the following changes:
SuffixType
enum (replaces the suffix constants)to_magnitude_and_suffix
function (instead of three)number_prefix
dependencyFixes #3422.