diff --git a/fixed_wide/src/narrow.rs b/fixed_wide/src/narrow.rs index ee18418..4ba82a9 100644 --- a/fixed_wide/src/narrow.rs +++ b/fixed_wide/src/narrow.rs @@ -34,4 +34,17 @@ mod tests { assert!(matches!(64i16.try_narrow(),Ok(64i8))); assert!(matches!((-257i16).try_narrow(),Err(NarrowError::Underflow))); } + + impl Narrow for fixed::FixedI16{ + type Output=i8; + fn narrow(self)->Self::Output{ + (self.to_bits()>>8) as i8 + } + } + + #[test] + fn test_fixed_i16_i8(){ + let a=fixed::FixedI16::::from(5)/2; + assert_eq!(a.narrow(),2); + } }