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:
Marcel Enguehard 2026-08-23 15:18:08 +02:00
parent 3ab4a4064a
commit 70086389f6

View file

@ -1,4 +1,4 @@
use std::fmt;
use std::{fmt, ops::Add};
use rust_decimal::{Decimal, prelude::ToPrimitive};
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)]
mod tests {
use super::*;