From 70086389f69357e9c838eee93356568e93af1e82 Mon Sep 17 00:00:00 2001 From: Marcel Enguehard Date: Sun, 23 Aug 2026 15:18:08 +0200 Subject: [PATCH] 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 --- crates/immo-core/src/euros.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/immo-core/src/euros.rs b/crates/immo-core/src/euros.rs index 1f38da0..7ad41f2 100644 --- a/crates/immo-core/src/euros.rs +++ b/crates/immo-core/src/euros.rs @@ -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::*;