From 8adaa2b5d1aa0b33869297de9634af4ef5697b01 Mon Sep 17 00:00:00 2001 From: Trevor Spiteri Date: Fri, 16 Aug 2019 20:31:41 +0200 Subject: [PATCH] add missing impl LossyFrom for Fixed which can represent 1 --- src/convert.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/convert.rs b/src/convert.rs index 2078d00..74d7121 100644 --- a/src/convert.rs +++ b/src/convert.rs @@ -312,6 +312,28 @@ macro_rules! bool_to_fixed { Self::from_bits(unshifted << shift) } } + + impl LossyFrom for $DstU + where + $DstBits: Sub, + U1: IsLessOrEqual, Output = True>, + { + #[inline] + fn lossy_from(src: bool) -> Self { + src.into() + } + } + + impl LossyFrom for $DstI + where + $DstBitsM1: Sub, + U1: IsLessOrEqual, Output = True>, + { + #[inline] + fn lossy_from(src: bool) -> Self { + src.into() + } + } }; } @@ -398,7 +420,6 @@ macro_rules! fixed_to_int_lossy { } } - // Conditions: $SrcBits - FracSrc <= $DstBitsM1 impl LossyFrom<$SrcU> for $DstI where $SrcBits: Sub,