From 0829f45b42bc5a4c9b1a6bdbf06883b102aad1cf Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 24 Mar 2021 12:52:29 +0000 Subject: [PATCH] Pos, Area: Provide Mean and middle for T=i32 Signed-off-by: Ian Jackson --- src/spec.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/spec.rs b/src/spec.rs index 0f2892cc..c2887734 100644 --- a/src/spec.rs +++ b/src/spec.rs @@ -278,6 +278,10 @@ pub mod pos_traits { pub trait Mean { fn mean(&self, other: &Self) -> Self; } + impl Mean for i32 { fn mean(&self, other: &Self) -> Self { + ((*self as i64 + *other as i64) / 2) as i32 + } } + impl Add> for PosC { type Output = Result; #[throws(CoordinateOverflow)] -- 2.30.2