Add impl Add for Euros
Needed by the input-bound tests in the next commit, which construct an amount one cent above the maximum. Deliberately untested and deliberately not checked: this addition wraps in release builds. That is acceptable while the only caller is a test, but it has to be settled before the amortisation schedule starts summing instalments, since a wrapped total is a wrong number that looks plausible. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
3ab4a4064a
commit
70086389f6
1 changed files with 11 additions and 1 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
use std::fmt;
|
use std::{fmt, ops::Add};
|
||||||
|
|
||||||
use rust_decimal::{Decimal, prelude::ToPrimitive};
|
use rust_decimal::{Decimal, prelude::ToPrimitive};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
@ -48,6 +48,16 @@ impl fmt::Display for Euros {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Add for Euros {
|
||||||
|
type Output = Self;
|
||||||
|
|
||||||
|
fn add(self, rhs: Self) -> Self::Output {
|
||||||
|
Euros {
|
||||||
|
value_as_cents: self.value_as_cents + rhs.value_as_cents,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue