Commit 7bf7a7ed authored by Stefan Schindler's avatar Stefan Schindler
Browse files

Fix the add_assign of ByteUnit

parent ce8c7bd5
...@@ -239,14 +239,18 @@ impl std::ops::AddAssign for ByteUnit { ...@@ -239,14 +239,18 @@ impl std::ops::AddAssign for ByteUnit {
fn add_assign(&mut self, other: Self) { fn add_assign(&mut self, other: Self) {
match self { match self {
&mut Byte(ref mut me) => match other { &mut Byte(ref mut me) => match other {
Byte(r) => { *me += r; }, Byte(r) => { *me += r; return },
KiloByte(r) => { *me += r * 1024; }, KiloByte(r) => { *me += r * 1024; return; },
}, },
&mut KiloByte(ref mut me) => match other { &mut KiloByte(ref mut me) => match other {
Byte(r) => *me += r / 1024, // FIXME: Rundungsfehler Byte(r) => { /* *me += r / 1024; würde zu einem Präzisions führen */ },
KiloByte(r) => *me += r, KiloByte(r) => { *me += r; return },
}, },
} }
// Change Type of self
let mut v = self.to_byte() + other;
std::mem::swap(self, &mut v);
} }
} }
impl std::ops::Sub for ByteUnit { impl std::ops::Sub for ByteUnit {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment