diff --git a/README.md b/README.md index d2e6d14..0e85e77 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,7 @@ The conversions supported cover the following cases. * [`unwrapped_rem`][f-ur-1-8], [`unwrapped_rem_euclid`][f-ure-1-8] * [`unwrapped_rem_int`][f-uri-1-8] + * Many methods were marked with the `must_use` attribute. [f-ur-1-8]: https://tspiteri.gitlab.io/fixed/dev/fixed/struct.FixedI32.html#method.unwrapped_rem [f-ure-1-8]: https://tspiteri.gitlab.io/fixed/dev/fixed/struct.FixedI32.html#method.unwrapped_rem_euclid diff --git a/RELEASES.md b/RELEASES.md index fecb89f..61f8ecf 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -13,6 +13,7 @@ Version 1.8.0 (unreleased) * [`unwrapped_rem`][f-ur-1-8], [`unwrapped_rem_euclid`][f-ure-1-8] * [`unwrapped_rem_int`][f-uri-1-8] + * Many methods were marked with the `must_use` attribute. [f-ur-1-8]: https://tspiteri.gitlab.io/fixed/dev/fixed/struct.FixedI32.html#method.unwrapped_rem [f-ure-1-8]: https://tspiteri.gitlab.io/fixed/dev/fixed/struct.FixedI32.html#method.unwrapped_rem_euclid diff --git a/src/macros_frac.rs b/src/macros_frac.rs index 31abb46..2005ed2 100644 --- a/src/macros_frac.rs +++ b/src/macros_frac.rs @@ -278,6 +278,7 @@ assert_eq!(Fix::from_num(7.5).div_euclid(Fix::from_num(2)), Fix::from_num(3)); [`wrapping_div_euclid`]: `Self::wrapping_div_euclid` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn div_euclid(self, rhs: $Fixed) -> $Fixed { let q = (self / rhs).round_to_zero(); if_signed! { @@ -329,6 +330,7 @@ assert_eq!(Fix::from_num(7.5).div_euclid_int(2), Fix::from_num(3)); [`wrapping_div_euclid_int`]: `Self::wrapping_div_euclid_int` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn div_euclid_int(self, rhs: $Inner) -> $Fixed { let q = (self / rhs).round_to_zero(); if_signed! { @@ -367,6 +369,7 @@ assert_eq!(Fix::from_num(7.5).rem_euclid_int(2), Fix::from_num(1.5)); "``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn rem_euclid_int(self, rhs: $Inner) -> $Fixed { let (ans, overflow) = self.overflowing_rem_euclid_int(rhs); debug_assert!(!overflow, "overflow"); @@ -429,6 +432,7 @@ assert_eq!(Fix::MAX.checked_mul(Fix::from_num(2)), None); ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn checked_mul(self, rhs: $Fixed) -> Option<$Fixed> { match self.to_bits().mul_overflow(rhs.to_bits(), Frac::U32) { (ans, false) => Some(Self::from_bits(ans)), @@ -451,6 +455,7 @@ assert_eq!(Fix::MAX.checked_div(Fix::from_num(1) / 2), None); ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn checked_div(self, rhs: $Fixed) -> Option<$Fixed> { if rhs.to_bits() == 0 { return None; @@ -509,6 +514,7 @@ assert_eq!(Fix::MAX.checked_div_euclid(Fix::from_num(0.25)), None); "``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn checked_div_euclid(self, rhs: $Fixed) -> Option<$Fixed> { let q = self.checked_div(rhs)?.round_to_zero(); if_signed! { @@ -545,6 +551,7 @@ assert_eq!(Fix::from_num(3.75).checked_rem_int(0), None); "``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn checked_rem_int(self, rhs: $Inner) -> Option<$Fixed> { // Overflow converting rhs to $Fixed means that either // * |rhs| > |self|, and so remainder is self, or @@ -592,6 +599,7 @@ assert_eq!(Fix::from_num(7.5).checked_div_euclid_int(0), None); "``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn checked_div_euclid_int(self, rhs: $Inner) -> Option<$Fixed> { let q = self.checked_div_int(rhs)?.round_to_zero(); if_signed! { @@ -635,6 +643,7 @@ assert_eq!(Fix::from_num(-7.5).checked_rem_euclid_int(20), None); "``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn checked_rem_euclid_int(self, rhs: $Inner) -> Option<$Fixed> { if_signed! { $Signedness; @@ -720,6 +729,7 @@ assert_eq!(Fix::MAX.saturating_mul(Fix::from_num(2)), Fix::MAX); ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn saturating_mul(self, rhs: $Fixed) -> $Fixed { match self.to_bits().mul_overflow(rhs.to_bits(), Frac::U32) { (ans, false) => Self::from_bits(ans), @@ -752,6 +762,7 @@ assert_eq!(Fix::MAX.saturating_div(one_half), Fix::MAX); ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn saturating_div(self, rhs: $Fixed) -> $Fixed { match self.to_bits().div_overflow(rhs.to_bits(), Frac::U32) { (ans, false) => Self::from_bits(ans), @@ -829,6 +840,7 @@ assert_eq!(Fix::MIN.saturating_div_euclid(Fix::from_num(0.25)), Fix::MIN); "``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn saturating_div_euclid(self, rhs: $Fixed) -> $Fixed { if rhs.to_bits() == 0 { panic!("division by zero"); @@ -899,6 +911,7 @@ assert_eq!(Fix::MAX.wrapping_mul(Fix::from_num(4)), wrapped); ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn wrapping_mul(self, rhs: $Fixed) -> $Fixed { let (ans, _) = self.to_bits().mul_overflow(rhs.to_bits(), Frac::U32); Self::from_bits(ans) @@ -925,6 +938,7 @@ assert_eq!(Fix::MAX.wrapping_div(quarter), wrapped); ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn wrapping_div(self, rhs: $Fixed) -> $Fixed { let (ans, _) = self.to_bits().div_overflow(rhs.to_bits(), Frac::U32); Self::from_bits(ans) @@ -973,6 +987,7 @@ assert_eq!(Fix::MAX.wrapping_div_euclid(Fix::from_num(0.25)), wrapped); ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn wrapping_div_euclid(self, rhs: $Fixed) -> $Fixed { self.overflowing_div_euclid(rhs).0 } @@ -1012,6 +1027,7 @@ assert_eq!(Fix::MIN.wrapping_div_euclid_int(-1), wrapped); "``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn wrapping_div_euclid_int(self, rhs: $Inner) -> $Fixed { self.overflowing_div_euclid_int(rhs).0 } @@ -1052,6 +1068,7 @@ assert_eq!(Fix::from_num(-7.5).wrapping_rem_euclid_int(20), Fix::from_num(-3.5)) "``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn wrapping_rem_euclid_int(self, rhs: $Inner) -> $Fixed { self.overflowing_rem_euclid_int(rhs).0 } @@ -1124,6 +1141,7 @@ let _overflow = Fix::MAX.unwrapped_mul(Fix::from_num(4)); "; #[inline] #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn unwrapped_mul(self, rhs: $Fixed) -> $Fixed { self.checked_mul(rhs).expect("overflow") } @@ -1156,6 +1174,7 @@ let _overflow = Fix::MAX.unwrapped_div(quarter); "; #[inline] #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn unwrapped_div(self, rhs: $Fixed) -> $Fixed { match self.overflowing_div(rhs) { (_, true) => panic!("overflow"), @@ -1215,6 +1234,7 @@ let _overflow = Fix::MAX.unwrapped_div_euclid(Fix::from_num(0.25)); "; #[inline] #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn unwrapped_div_euclid(self, rhs: $Fixed) -> $Fixed { match self.overflowing_div_euclid(rhs) { (_, true) => panic!("overflow"), @@ -1249,6 +1269,7 @@ let _divisor_is_zero = Fix::from_num(3.75).unwrapped_rem_int(0); "; #[inline] #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn unwrapped_rem_int(self, rhs: $Inner) -> $Fixed { self.checked_rem_int(rhs).expect("division by zero") } @@ -1300,6 +1321,7 @@ let _overflow = Fix::MIN.unwrapped_div_euclid_int(-1); "; #[inline] #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn unwrapped_div_euclid_int(self, rhs: $Inner) -> $Fixed { match self.overflowing_div_euclid_int(rhs) { (_, true) => panic!("overflow"), @@ -1356,6 +1378,7 @@ let _overflow = Fix::from_num(-7.5).unwrapped_rem_euclid_int(20); "; #[inline] #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn unwrapped_rem_euclid_int(self, rhs: $Inner) -> $Fixed { match self.overflowing_rem_euclid_int(rhs) { (_, true) => panic!("overflow"), @@ -1425,6 +1448,7 @@ assert_eq!(Fix::MAX.overflowing_mul(Fix::from_num(4)), (wrapped, true)); ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn overflowing_mul(self, rhs: $Fixed) -> ($Fixed, bool) { let (ans, overflow) = self.to_bits().mul_overflow(rhs.to_bits(), Frac::U32); (Self::from_bits(ans), overflow) @@ -1454,6 +1478,7 @@ assert_eq!(Fix::MAX.overflowing_div(quarter), (wrapped, true)); ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn overflowing_div(self, rhs: $Fixed) -> ($Fixed, bool) { let (ans, overflow) = self.to_bits().div_overflow(rhs.to_bits(), Frac::U32); (Self::from_bits(ans), overflow) @@ -1541,6 +1566,7 @@ assert_eq!(Fix::MAX.overflowing_div_euclid(Fix::from_num(0.25)), (wrapped, true) ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn overflowing_div_euclid(self, rhs: $Fixed) -> ($Fixed, bool) { let (mut q, overflow) = self.overflowing_div(rhs); q = q.round_to_zero(); @@ -1601,6 +1627,7 @@ assert_eq!(Fix::MIN.overflowing_div_euclid_int(-1), (wrapped, true)); "``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn overflowing_div_euclid_int(self, rhs: $Inner) -> ($Fixed, bool) { let (mut q, overflow) = self.overflowing_div_int(rhs); q = q.round_to_zero(); @@ -1663,6 +1690,7 @@ assert_eq!(Fix::from_num(-7.5).overflowing_rem_euclid_int(20), (Fix::from_num(-3 "``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn overflowing_rem_euclid_int(self, rhs: $Inner) -> ($Fixed, bool) { if_signed! { $Signedness; diff --git a/src/macros_no_frac.rs b/src/macros_no_frac.rs index 6b2a1f3..c5d2b70 100644 --- a/src/macros_no_frac.rs +++ b/src/macros_no_frac.rs @@ -539,6 +539,7 @@ assert_eq!(Fix::from_bits(bits).reverse_bits(), Fix::from_bits(rev_bits)); ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub const fn reverse_bits(self) -> $Fixed { $Fixed::from_bits(self.to_bits().reverse_bits()) } @@ -560,6 +561,7 @@ assert_eq!(Fix::from_bits(bits).rotate_left(3), Fix::from_bits(rot)); ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub const fn rotate_left(self, n: u32) -> $Fixed { Self::from_bits(self.to_bits().rotate_left(n)) } @@ -581,6 +583,7 @@ assert_eq!(Fix::from_bits(bits).rotate_right(3), Fix::from_bits(rot)); ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub const fn rotate_right(self, n: u32) -> $Fixed { Self::from_bits(self.to_bits().rotate_right(n)) } @@ -679,6 +682,7 @@ assert_eq!(a.wide_mul(b), 1.328_125); ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn wide_mul( self, rhs: $Fixed, @@ -738,6 +742,7 @@ assert_eq!(Fix::MAX.mul_add(Fix::from_num(1.5), -Fix::MAX), Fix::MAX / 2); [`wrapping_mul_add`]: `Self::wrapping_mul_add` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn mul_add( self, mul: $Fixed, @@ -775,6 +780,7 @@ assert_eq!(Fix::from_num(7.5).rem_euclid(Fix::from_num(2)), Fix::from_num(1.5)); "``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn rem_euclid(self, rhs: $Fixed) -> $Fixed { let rhs_bits = rhs.to_bits(); if_signed! { @@ -914,6 +920,7 @@ assert_eq!(Fix::from_num(3).mean(Fix::from_num(4)), Fix::from_num(3.5)); "``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub const fn mean(self, other: $Fixed) -> $Fixed { // a & b == common bits // a ^ b == different bits @@ -974,6 +981,7 @@ assert_eq!(Fix::MAX.checked_add(one), None); ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub const fn checked_add(self, rhs: $Fixed) -> Option<$Fixed> { match self.to_bits().checked_add(rhs.to_bits()) { None => None, @@ -996,6 +1004,7 @@ assert_eq!(Fix::MIN.checked_sub(one), None); ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub const fn checked_sub(self, rhs: $Fixed) -> Option<$Fixed> { match self.to_bits().checked_sub(rhs.to_bits()) { None => None, @@ -1018,6 +1027,7 @@ assert_eq!(Fix::from_num(1.5).checked_rem(Fix::from_num(0)), None); ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn checked_rem(self, rhs: $Fixed) -> Option<$Fixed> { let rhs_bits = rhs.to_bits(); if_signed! { @@ -1071,6 +1081,7 @@ assert_eq!(Fix::MAX.checked_mul_add(Fix::from_num(1.5), -Fix::MAX), Some(Fix::MA "``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn checked_mul_add( self, mul: $Fixed, @@ -1101,6 +1112,7 @@ assert_eq!(Fix::MAX.checked_mul_int(2), None); ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub const fn checked_mul_int(self, rhs: $Inner) -> Option<$Fixed> { match self.to_bits().checked_mul(rhs) { None => None, @@ -1135,6 +1147,7 @@ assert_eq!(Fix::from_num(1).checked_div_int(0), None); "``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn checked_div_int(self, rhs: $Inner) -> Option<$Fixed> { match self.to_bits().checked_div(rhs) { None => None, @@ -1164,6 +1177,7 @@ assert_eq!(num.checked_rem_euclid(Fix::from_num(0)), None); "``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn checked_rem_euclid(self, rhs: $Fixed) -> Option<$Fixed> { let rhs_bits = rhs.to_bits(); if_signed! { @@ -1193,6 +1207,7 @@ assert_eq!((Fix::from_num(1) / 2).checked_shl(", $s_nbits, "), None); ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub const fn checked_shl(self, rhs: u32) -> Option<$Fixed> { match self.to_bits().checked_shl(rhs) { None => None, @@ -1215,6 +1230,7 @@ assert_eq!(Fix::from_num(4).checked_shr(", $s_nbits, "), None); ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub const fn checked_shr(self, rhs: u32) -> Option<$Fixed> { match self.to_bits().checked_shr(rhs) { None => None, @@ -1333,6 +1349,7 @@ assert_eq!(Fix::MAX.saturating_add(Fix::from_num(1)), Fix::MAX); ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub const fn saturating_add(self, rhs: $Fixed) -> $Fixed { match self.overflowing_add(rhs) { (val, false) => val, @@ -1365,6 +1382,7 @@ assert_eq!(Fix::from_num(0).saturating_sub(Fix::from_num(1)), Fix::from_num(0)); ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub const fn saturating_sub(self, rhs: $Fixed) -> $Fixed { match self.overflowing_sub(rhs) { (val, false) => val, @@ -1420,6 +1438,7 @@ assert_eq!(Fix::MAX.saturating_mul_add(Fix::from_num(1.5), -Fix::MAX), half_max) "``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn saturating_mul_add( self, mul: $Fixed, @@ -1460,6 +1479,7 @@ assert_eq!(Fix::MAX.saturating_mul_int(2), Fix::MAX); ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub const fn saturating_mul_int(self, rhs: $Inner) -> $Fixed { match self.overflowing_mul_int(rhs) { (val, false) => val, @@ -1554,6 +1574,7 @@ assert_eq!(Fix::MAX.wrapping_add(one), ", ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub const fn wrapping_add(self, rhs: $Fixed) -> $Fixed { Self::from_bits(self.to_bits().wrapping_add(rhs.to_bits())) } @@ -1581,6 +1602,7 @@ assert_eq!(Fix::from_num(0)", ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub const fn wrapping_sub(self, rhs: $Fixed) -> $Fixed { Self::from_bits(self.to_bits().wrapping_sub(rhs.to_bits())) } @@ -1609,6 +1631,7 @@ assert_eq!(Fix::MAX.wrapping_mul_add(Fix::from_num(3), Fix::MAX), wrapped); ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn wrapping_mul_add( self, mul: $Fixed, @@ -1637,6 +1660,7 @@ assert_eq!(Fix::MAX.wrapping_mul_int(4), wrapped); ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub const fn wrapping_mul_int(self, rhs: $Inner) -> $Fixed { Self::from_bits(self.to_bits().wrapping_mul(rhs)) } @@ -1676,6 +1700,7 @@ assert_eq!(Fix::from_num(3).wrapping_div_int(2), one_point_5); "``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn wrapping_div_int(self, rhs: $Inner) -> $Fixed { Self::from_bits(self.to_bits().wrapping_div(rhs)) } @@ -1695,6 +1720,7 @@ assert_eq!((Fix::from_num(1) / 2).wrapping_shl(3 + ", $s_nbits, "), Fix::from_nu ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub const fn wrapping_shl(self, rhs: u32) -> $Fixed { Self::from_bits(self.to_bits().wrapping_shl(rhs)) } @@ -1714,6 +1740,7 @@ assert_eq!((Fix::from_num(4)).wrapping_shr(3 + ", $s_nbits, "), Fix::from_num(1) ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub const fn wrapping_shr(self, rhs: u32) -> $Fixed { Self::from_bits(self.to_bits().wrapping_shr(rhs)) } @@ -1852,6 +1879,7 @@ let _overflow = Fix::MAX.unwrapped_add(Fix::from_bits(1)); "; #[inline] #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn unwrapped_add(self, rhs: $Fixed) -> $Fixed { self.checked_add(rhs).expect("overflow") } @@ -1889,6 +1917,7 @@ let _overflow = Fix::MIN.unwrapped_sub(Fix::from_bits(1)); "; #[inline] #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn unwrapped_sub(self, rhs: $Fixed) -> $Fixed { self.checked_sub(rhs).expect("overflow") } @@ -1919,6 +1948,7 @@ let _divisor_is_zero = Fix::from_num(1.5).unwrapped_rem(Fix::from_num(0)); "; #[inline] #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn unwrapped_rem(self, rhs: $Fixed) -> $Fixed { self.checked_rem(rhs).expect("division by zero") } @@ -1973,6 +2003,7 @@ let _overflow = Fix::MAX.unwrapped_mul_add(Fix::from_num(1), Fix::from_bits(1)); "; #[inline] #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn unwrapped_mul_add( self, mul: $Fixed, @@ -2007,6 +2038,7 @@ let _overflow = Fix::MAX.unwrapped_mul_int(4); "; #[inline] #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn unwrapped_mul_int(self, rhs: $Inner) -> $Fixed { self.checked_mul_int(rhs).expect("overflow") } @@ -2059,6 +2091,7 @@ let _overflow = Fix::MIN.unwrapped_div_int(-1); "; #[inline] #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn unwrapped_div_int(self, rhs: $Inner) -> $Fixed { match self.overflowing_div_int(rhs) { (_, true) => panic!("overflow"), @@ -2091,6 +2124,7 @@ let _divisor_is_zero = Fix::from_num(3).unwrapped_rem_euclid(Fix::from_num(0)); "; #[inline] #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn unwrapped_rem_euclid(self, rhs: $Fixed) -> $Fixed { self.checked_rem_euclid(rhs).expect("division by zero") } @@ -2121,6 +2155,7 @@ let _overflow = Fix::from_num(1).unwrapped_shl(", $s_nbits, "); "; #[inline] #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn unwrapped_shl(self, rhs: u32) -> $Fixed { self.checked_shl(rhs).expect("overflow") } @@ -2151,6 +2186,7 @@ let _overflow = Fix::from_num(1).unwrapped_shr(", $s_nbits, "); "; #[inline] #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn unwrapped_shr(self, rhs: u32) -> $Fixed { self.checked_shr(rhs).expect("overflow") } @@ -2288,6 +2324,7 @@ assert_eq!(Fix::MAX.overflowing_add(one), (", ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub const fn overflowing_add(self, rhs: $Fixed) -> ($Fixed, bool) { let (ans, o) = self.to_bits().overflowing_add(rhs.to_bits()); (Self::from_bits(ans), o) @@ -2319,6 +2356,7 @@ assert_eq!(Fix::from_num(0)", ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub const fn overflowing_sub(self, rhs: $Fixed) -> ($Fixed, bool) { let (ans, o) = self.to_bits().overflowing_sub(rhs.to_bits()); (Self::from_bits(ans), o) @@ -2365,6 +2403,7 @@ assert_eq!( "``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn overflowing_mul_add( self, mul: $Fixed, @@ -2396,6 +2435,7 @@ assert_eq!(Fix::MAX.overflowing_mul_int(4), (wrapped, true)); ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub const fn overflowing_mul_int(self, rhs: $Inner) -> ($Fixed, bool) { let (ans, o) = self.to_bits().overflowing_mul(rhs); (Self::from_bits(ans), o) @@ -2436,6 +2476,7 @@ assert_eq!(Fix::from_num(3).overflowing_div_int(2), (one_point_5, false)); "``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn overflowing_div_int(self, rhs: $Inner) -> ($Fixed, bool) { let (ans, o) = self.to_bits().overflowing_div(rhs); (Self::from_bits(ans), o) @@ -2459,6 +2500,7 @@ assert_eq!((Fix::from_num(1) / 2).overflowing_shl(3 + ", $s_nbits, "), (Fix::fro ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub const fn overflowing_shl(self, rhs: u32) -> ($Fixed, bool) { let (ans, o) = self.to_bits().overflowing_shl(rhs); (Self::from_bits(ans), o) @@ -2482,6 +2524,7 @@ assert_eq!((Fix::from_num(4)).overflowing_shr(3 + ", $s_nbits, "), (Fix::from_nu ``` "; #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub const fn overflowing_shr(self, rhs: u32) -> ($Fixed, bool) { let (ans, o) = self.to_bits().overflowing_shr(rhs); (Self::from_bits(ans), o) diff --git a/src/traits.rs b/src/traits.rs index 20721f8..c4212ed 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -718,15 +718,19 @@ where fn checked_int_log10(self) -> Option; /// Reverses the order of the bits of the fixed-point number. + #[must_use = "this returns the result of the operation, without modifying the original"] fn reverse_bits(self) -> Self; /// Shifts to the left by `n` bits, wrapping the truncated bits to the right end. + #[must_use = "this returns the result of the operation, without modifying the original"] fn rotate_left(self, n: u32) -> Self; /// Shifts to the right by `n` bits, wrapping the truncated bits to the left end. + #[must_use = "this returns the result of the operation, without modifying the original"] fn rotate_right(self, n: u32) -> Self; /// Returns the mean of `self` and `other`. + #[must_use = "this returns the result of the operation, without modifying the original"] fn mean(self, other: Self) -> Self; /// Returns the reciprocal. @@ -744,6 +748,7 @@ where /// fractional bits. /// /// [`mul_add`]: `FixedI32::mul_add` + #[must_use = "this returns the result of the operation, without modifying the original"] fn mul_add(self, mul: Self, add: Self) -> Self; /// Euclidean division by an integer. @@ -751,6 +756,7 @@ where /// # Panics /// /// Panics if the divisor is zero or if the division results in overflow. + #[must_use = "this returns the result of the operation, without modifying the original"] fn div_euclid(self, rhs: Self) -> Self; /// Remainder for Euclidean division. @@ -758,6 +764,7 @@ where /// # Panics /// /// Panics if the divisor is zero. + #[must_use = "this returns the result of the operation, without modifying the original"] fn rem_euclid(self, rhs: Self) -> Self; /// Euclidean division by an integer. @@ -765,6 +772,7 @@ where /// # Panics /// /// Panics if the divisor is zero or if the division results in overflow. + #[must_use = "this returns the result of the operation, without modifying the original"] fn div_euclid_int(self, rhs: Self::Bits) -> Self; /// Remainder for Euclidean division by an integer. @@ -772,26 +780,32 @@ where /// # Panics /// /// Panics if the divisor is zero or if the division results in overflow. + #[must_use = "this returns the result of the operation, without modifying the original"] fn rem_euclid_int(self, rhs: Self::Bits) -> Self; /// Checked negation. Returns the negated value, or [`None`] on overflow. fn checked_neg(self) -> Option; /// Checked addition. Returns the sum, or [`None`] on overflow. + #[must_use = "this returns the result of the operation, without modifying the original"] fn checked_add(self, rhs: Self) -> Option; /// Checked subtraction. Returns the difference, or [`None`] on overflow. + #[must_use = "this returns the result of the operation, without modifying the original"] fn checked_sub(self, rhs: Self) -> Option; /// Checked multiplication. Returns the product, or [`None`] on overflow. + #[must_use = "this returns the result of the operation, without modifying the original"] fn checked_mul(self, rhs: Self) -> Option; /// Checked division. Returns the quotient, or [`None`] if the /// divisor is zero or on overflow. + #[must_use = "this returns the result of the operation, without modifying the original"] fn checked_div(self, rhs: Self) -> Option; /// Checked remainder. Returns the remainder, or [`None`] if the /// divisor is zero. + #[must_use = "this returns the result of the operation, without modifying the original"] fn checked_rem(self, rhs: Self) -> Option; /// Checked reciprocal. Returns the reciprocal, or [`None`] if @@ -799,59 +813,72 @@ where fn checked_recip(self) -> Option; /// Checked multiply and add. Returns `self` × `mul` + `add`, or [`None`] on overflow. + #[must_use = "this returns the result of the operation, without modifying the original"] fn checked_mul_add(self, mul: Self, add: Self) -> Option; /// Checked remainder for Euclidean division. Returns the /// remainder, or [`None`] if the divisor is zero or the division /// results in overflow. + #[must_use = "this returns the result of the operation, without modifying the original"] fn checked_div_euclid(self, rhs: Self) -> Option; /// Checked remainder for Euclidean division. Returns the /// remainder, or [`None`] if the divisor is zero. + #[must_use = "this returns the result of the operation, without modifying the original"] fn checked_rem_euclid(self, rhs: Self) -> Option; /// Checked multiplication by an integer. Returns the product, or /// [`None`] on overflow. + #[must_use = "this returns the result of the operation, without modifying the original"] fn checked_mul_int(self, rhs: Self::Bits) -> Option; /// Checked division by an integer. Returns the quotient, or /// [`None`] if the divisor is zero or if the division results in /// overflow. + #[must_use = "this returns the result of the operation, without modifying the original"] fn checked_div_int(self, rhs: Self::Bits) -> Option; /// Checked fixed-point remainder for division by an integer. /// Returns the remainder, or [`None`] if the divisor is zero or /// if the division results in overflow. + #[must_use = "this returns the result of the operation, without modifying the original"] fn checked_rem_int(self, rhs: Self::Bits) -> Option; /// Checked Euclidean division by an integer. Returns the /// quotient, or [`None`] if the divisor is zero or if the /// division results in overflow. + #[must_use = "this returns the result of the operation, without modifying the original"] fn checked_div_euclid_int(self, rhs: Self::Bits) -> Option; /// Checked remainder for Euclidean division by an integer. /// Returns the remainder, or [`None`] if the divisor is zero or /// if the remainder results in overflow. + #[must_use = "this returns the result of the operation, without modifying the original"] fn checked_rem_euclid_int(self, rhs: Self::Bits) -> Option; /// Checked shift left. Returns the shifted number, or [`None`] if /// `rhs` ≥ the number of bits. + #[must_use = "this returns the result of the operation, without modifying the original"] fn checked_shl(self, rhs: u32) -> Option; /// Checked shift right. Returns the shifted number, or [`None`] /// if `rhs` ≥ the number of bits. + #[must_use = "this returns the result of the operation, without modifying the original"] fn checked_shr(self, rhs: u32) -> Option; /// Saturated negation. Returns the negated value, saturating on overflow. fn saturating_neg(self) -> Self; /// Saturating addition. Returns the sum, saturating on overflow. + #[must_use = "this returns the result of the operation, without modifying the original"] fn saturating_add(self, rhs: Self) -> Self; /// Saturating subtraction. Returns the difference, saturating on overflow. + #[must_use = "this returns the result of the operation, without modifying the original"] fn saturating_sub(self, rhs: Self) -> Self; /// Saturating multiplication. Returns the product, saturating on overflow. + #[must_use = "this returns the result of the operation, without modifying the original"] fn saturating_mul(self, rhs: Self) -> Self; /// Saturating division. Returns the quotient, saturating on overflow. @@ -859,6 +886,7 @@ where /// # Panics /// /// Panics if the divisor is zero. + #[must_use = "this returns the result of the operation, without modifying the original"] fn saturating_div(self, rhs: Self) -> Self; /// Saturating reciprocal. @@ -869,6 +897,7 @@ where fn saturating_recip(self) -> Self; /// Saturating multiply and add. Returns `self` × `mul` + `add`, saturating on overflow. + #[must_use = "this returns the result of the operation, without modifying the original"] fn saturating_mul_add(self, mul: Self, add: Self) -> Self; /// Saturating Euclidean division. Returns the quotient, saturating on overflow. @@ -876,21 +905,26 @@ where /// # Panics /// /// Panics if the divisor is zero. + #[must_use = "this returns the result of the operation, without modifying the original"] fn saturating_div_euclid(self, rhs: Self) -> Self; /// Saturating multiplication by an integer. Returns the product, saturating on overflow. + #[must_use = "this returns the result of the operation, without modifying the original"] fn saturating_mul_int(self, rhs: Self::Bits) -> Self; /// Wrapping negation. Returns the negated value, wrapping on overflow. fn wrapping_neg(self) -> Self; /// Wrapping addition. Returns the sum, wrapping on overflow. + #[must_use = "this returns the result of the operation, without modifying the original"] fn wrapping_add(self, rhs: Self) -> Self; /// Wrapping subtraction. Returns the difference, wrapping on overflow. + #[must_use = "this returns the result of the operation, without modifying the original"] fn wrapping_sub(self, rhs: Self) -> Self; /// Wrapping multiplication. Returns the product, wrapping on overflow. + #[must_use = "this returns the result of the operation, without modifying the original"] fn wrapping_mul(self, rhs: Self) -> Self; /// Wrapping division. Returns the quotient, wrapping on overflow. @@ -898,6 +932,7 @@ where /// # Panics /// /// Panics if the divisor is zero. + #[must_use = "this returns the result of the operation, without modifying the original"] fn wrapping_div(self, rhs: Self) -> Self; /// Wrapping reciprocal. @@ -908,6 +943,7 @@ where fn wrapping_recip(self) -> Self; /// Wrapping multiply and add. Returns `self` × `mul` + `add`, wrapping on overflow. + #[must_use = "this returns the result of the operation, without modifying the original"] fn wrapping_mul_add(self, mul: Self, add: Self) -> Self; /// Wrapping Euclidean division. Returns the quotient, wrapping on overflow. @@ -915,9 +951,11 @@ where /// # Panics /// /// Panics if the divisor is zero. + #[must_use = "this returns the result of the operation, without modifying the original"] fn wrapping_div_euclid(self, rhs: Self) -> Self; /// Wrapping multiplication by an integer. Returns the product, wrapping on overflow. + #[must_use = "this returns the result of the operation, without modifying the original"] fn wrapping_mul_int(self, rhs: Self::Bits) -> Self; /// Wrapping division by an integer. Returns the quotient, wrapping on overflow. @@ -927,6 +965,7 @@ where /// # Panics /// /// Panics if the divisor is zero. + #[must_use = "this returns the result of the operation, without modifying the original"] fn wrapping_div_int(self, rhs: Self::Bits) -> Self; /// Wrapping Euclidean division by an integer. Returns the @@ -937,6 +976,7 @@ where /// # Panics /// /// Panics if the divisor is zero. + #[must_use = "this returns the result of the operation, without modifying the original"] fn wrapping_div_euclid_int(self, rhs: Self::Bits) -> Self; /// Wrapping remainder for Euclidean division by an integer. @@ -945,14 +985,17 @@ where /// # Panics /// /// Panics if the divisor is zero. + #[must_use = "this returns the result of the operation, without modifying the original"] fn wrapping_rem_euclid_int(self, rhs: Self::Bits) -> Self; /// Wrapping shift left. Wraps `rhs` if `rhs` ≥ the number of /// bits, then shifts and returns the number. + #[must_use = "this returns the result of the operation, without modifying the original"] fn wrapping_shl(self, rhs: u32) -> Self; /// Wrapping shift right. Wraps `rhs` if `rhs` ≥ the number of /// bits, then shifts and returns the number. + #[must_use = "this returns the result of the operation, without modifying the original"] fn wrapping_shr(self, rhs: u32) -> Self; /// Unwrapped negation. Returns the negated value, panicking on overflow. @@ -969,6 +1012,7 @@ where /// /// Panics if the result does not fit. #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] fn unwrapped_add(self, rhs: Self) -> Self; /// Unwrapped subtraction. Returns the difference, panicking on overflow. @@ -977,6 +1021,7 @@ where /// /// Panics if the result does not fit. #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] fn unwrapped_sub(self, rhs: Self) -> Self; /// Unwrapped multiplication. Returns the product, panicking on overflow. @@ -985,6 +1030,7 @@ where /// /// Panics if the result does not fit. #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] fn unwrapped_mul(self, rhs: Self) -> Self; /// Unwrapped division. Returns the quotient, panicking on overflow. @@ -993,6 +1039,7 @@ where /// /// Panics if the divisor is zero or if the result does not fit. #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] fn unwrapped_div(self, rhs: Self) -> Self; /// Unwrapped remainder. Returns the quotient, panicking if the divisor is zero. @@ -1001,6 +1048,7 @@ where /// /// Panics if the divisor is zero. #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] fn unwrapped_rem(self, rhs: Self) -> Self; /// Unwrapped reciprocal. Returns reciprocal, panicking on overflow. @@ -1017,6 +1065,7 @@ where /// /// Panics if the result does not fit. #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] fn unwrapped_mul_add(self, mul: Self, add: Self) -> Self; /// Unwrapped Euclidean division. Returns the quotient, panicking on overflow. @@ -1025,6 +1074,7 @@ where /// /// Panics if the divisor is zero or if the result does not fit. #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] fn unwrapped_div_euclid(self, rhs: Self) -> Self; /// Unwrapped remainder for Euclidean division. Returns the @@ -1034,6 +1084,7 @@ where /// /// Panics if the divisor is zero. #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] fn unwrapped_rem_euclid(self, rhs: Self) -> Self; /// Unwrapped multiplication by an integer. Returns the product, panicking on overflow. @@ -1042,6 +1093,7 @@ where /// /// Panics if the result does not fit. #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] fn unwrapped_mul_int(self, rhs: Self::Bits) -> Self; /// Unwrapped division by an integer. Returns the quotient, panicking on overflow. @@ -1052,6 +1104,7 @@ where /// /// Panics if the divisor is zero or if the result does not fit. #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] fn unwrapped_div_int(self, rhs: Self::Bits) -> Self; /// Unwrapped remainder for division by an integer. Returns the @@ -1061,6 +1114,7 @@ where /// /// Panics if the divisor is zero. #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] fn unwrapped_rem_int(self, rhs: Self::Bits) -> Self; /// Unwrapped Euclidean division by an integer. Returns the @@ -1072,6 +1126,7 @@ where /// /// Panics if the divisor is zero or if the result does not fit. #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] fn unwrapped_div_euclid_int(self, rhs: Self::Bits) -> Self; /// Unwrapped remainder for Euclidean division by an integer. @@ -1081,6 +1136,7 @@ where /// /// Panics if the divisor is zero or if the result does not fit. #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] fn unwrapped_rem_euclid_int(self, rhs: Self::Bits) -> Self; /// Unwrapped shift left. Panics if `rhs` ≥ the number of bits. @@ -1089,6 +1145,7 @@ where /// /// Panics if `rhs` ≥ the number of bits. #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] fn unwrapped_shl(self, rhs: u32) -> Self; /// Unwrapped shift right. Panics if `rhs` ≥ the number of bits. @@ -1097,6 +1154,7 @@ where /// /// Panics if `rhs` ≥ the number of bits. #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] fn unwrapped_shr(self, rhs: u32) -> Self; /// Overflowing negation. @@ -1111,6 +1169,7 @@ where /// Returns a [tuple] of the sum and a [`bool`], indicating whether /// an overflow has occurred. On overflow, the wrapped value is /// returned. + #[must_use = "this returns the result of the operation, without modifying the original"] fn overflowing_add(self, rhs: Self) -> (Self, bool); /// Overflowing subtraction. @@ -1118,6 +1177,7 @@ where /// Returns a [tuple] of the difference and a [`bool`], indicating /// whether an overflow has occurred. On overflow, the wrapped /// value is returned. + #[must_use = "this returns the result of the operation, without modifying the original"] fn overflowing_sub(self, rhs: Self) -> (Self, bool); /// Overflowing multiplication. @@ -1125,6 +1185,7 @@ where /// Returns a [tuple] of the product and a [`bool`], indicating /// whether an overflow has occurred. On overflow, the wrapped /// value is returned. + #[must_use = "this returns the result of the operation, without modifying the original"] fn overflowing_mul(self, rhs: Self) -> (Self, bool); /// Overflowing division. @@ -1136,6 +1197,7 @@ where /// # Panics /// /// Panics if the divisor is zero. + #[must_use = "this returns the result of the operation, without modifying the original"] fn overflowing_div(self, rhs: Self) -> (Self, bool); /// Overflowing reciprocal. @@ -1154,6 +1216,7 @@ where /// Returns a [tuple] of `self` × `mul` + `add` and a [`bool`], /// indicating whether an overflow has occurred. On overflow, the /// wrapped value is returned. + #[must_use = "this returns the result of the operation, without modifying the original"] fn overflowing_mul_add(self, mul: Self, add: Self) -> (Self, bool); /// Overflowing Euclidean division. @@ -1165,6 +1228,7 @@ where /// # Panics /// /// Panics if the divisor is zero. + #[must_use = "this returns the result of the operation, without modifying the original"] fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool); /// Overflowing multiplication by an integer. @@ -1172,6 +1236,7 @@ where /// Returns a [tuple] of the product and a [`bool`], indicating /// whether an overflow has occurred. On overflow, the wrapped /// value is returned. + #[must_use = "this returns the result of the operation, without modifying the original"] fn overflowing_mul_int(self, rhs: Self::Bits) -> (Self, bool); /// Overflowing division by an integer. @@ -1183,6 +1248,7 @@ where /// # Panics /// /// Panics if the divisor is zero. + #[must_use = "this returns the result of the operation, without modifying the original"] fn overflowing_div_int(self, rhs: Self::Bits) -> (Self, bool); /// Overflowing Euclidean division by an integer. @@ -1194,6 +1260,7 @@ where /// # Panics /// /// Panics if the divisor is zero. + #[must_use = "this returns the result of the operation, without modifying the original"] fn overflowing_div_euclid_int(self, rhs: Self::Bits) -> (Self, bool); /// Overflowing remainder for Euclidean division by an integer. @@ -1205,6 +1272,7 @@ where /// # Panics /// /// Panics if the divisor is zero. + #[must_use = "this returns the result of the operation, without modifying the original"] fn overflowing_rem_euclid_int(self, rhs: Self::Bits) -> (Self, bool); /// Overflowing shift left. @@ -1212,6 +1280,7 @@ where /// Returns a [tuple] of the shifted value and a [`bool`], /// indicating whether an overflow has occurred. On overflow, the /// wrapped value is returned. + #[must_use = "this returns the result of the operation, without modifying the original"] fn overflowing_shl(self, rhs: u32) -> (Self, bool); /// Overflowing shift right. @@ -1219,6 +1288,7 @@ where /// Returns a [tuple] of the shifted value and a [`bool`], /// indicating whether an overflow has occurred. On overflow, the /// wrapped value is returned. + #[must_use = "this returns the result of the operation, without modifying the original"] fn overflowing_shr(self, rhs: u32) -> (Self, bool); } diff --git a/src/unwrapped.rs b/src/unwrapped.rs index 1b615b4..eb0831f 100644 --- a/src/unwrapped.rs +++ b/src/unwrapped.rs @@ -788,6 +788,7 @@ impl Unwrapped { /// assert_eq!(Unwrapped(i).reverse_bits(), Unwrapped(i.reverse_bits())); /// ``` #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn reverse_bits(self) -> Unwrapped { Unwrapped(self.0.reverse_bits()) } @@ -802,6 +803,7 @@ impl Unwrapped { /// assert_eq!(Unwrapped(i).rotate_left(12), Unwrapped(i.rotate_left(12))); /// ``` #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn rotate_left(self, n: u32) -> Unwrapped { Unwrapped(self.0.rotate_left(n)) } @@ -816,6 +818,7 @@ impl Unwrapped { /// assert_eq!(Unwrapped(i).rotate_right(12), Unwrapped(i.rotate_right(12))); /// ``` #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn rotate_right(self, n: u32) -> Unwrapped { Unwrapped(self.0.rotate_right(n)) } @@ -832,6 +835,7 @@ impl Unwrapped { /// assert_eq!(three.mean(-four), Unwrapped(I16F16::from_num(-0.5))); /// ``` #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn mean(self, other: Unwrapped) -> Unwrapped { Unwrapped(self.0.mean(other.0)) } @@ -892,6 +896,7 @@ impl Unwrapped { /// ``` #[inline] #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn mul_add(self, mul: Unwrapped, add: Unwrapped) -> Unwrapped { Unwrapped(self.0.unwrapped_mul_add(mul.0, add.0)) } @@ -920,6 +925,7 @@ impl Unwrapped { /// ``` #[inline] #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn div_euclid(self, divisor: Unwrapped) -> Unwrapped { Unwrapped(self.0.unwrapped_div_euclid(divisor.0)) } @@ -941,6 +947,7 @@ impl Unwrapped { /// ``` #[inline] #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn rem_euclid(self, divisor: Unwrapped) -> Unwrapped { Unwrapped(self.0.unwrapped_rem_euclid(divisor.0)) } @@ -968,6 +975,7 @@ impl Unwrapped { /// ``` #[inline] #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn div_euclid_int(self, divisor: F::Bits) -> Unwrapped { Unwrapped(self.0.unwrapped_div_euclid_int(divisor)) } @@ -997,6 +1005,7 @@ impl Unwrapped { /// ``` #[inline] #[track_caller] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn rem_euclid_int(self, divisor: F::Bits) -> Unwrapped { Unwrapped(self.0.unwrapped_rem_euclid_int(divisor)) } diff --git a/src/wrapping.rs b/src/wrapping.rs index e67a4b3..bd95b0b 100644 --- a/src/wrapping.rs +++ b/src/wrapping.rs @@ -730,6 +730,7 @@ impl Wrapping { /// assert_eq!(Wrapping(i).reverse_bits(), Wrapping(i.reverse_bits())); /// ``` #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn reverse_bits(self) -> Wrapping { Wrapping(self.0.reverse_bits()) } @@ -744,6 +745,7 @@ impl Wrapping { /// assert_eq!(Wrapping(i).rotate_left(12), Wrapping(i.rotate_left(12))); /// ``` #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn rotate_left(self, n: u32) -> Wrapping { Wrapping(self.0.rotate_left(n)) } @@ -758,6 +760,7 @@ impl Wrapping { /// assert_eq!(Wrapping(i).rotate_right(12), Wrapping(i.rotate_right(12))); /// ``` #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn rotate_right(self, n: u32) -> Wrapping { Wrapping(self.0.rotate_right(n)) } @@ -774,6 +777,7 @@ impl Wrapping { /// assert_eq!(three.mean(-four), Wrapping(I16F16::from_num(-0.5))); /// ``` #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn mean(self, other: Wrapping) -> Wrapping { Wrapping(self.0.mean(other.0)) } @@ -812,6 +816,7 @@ impl Wrapping { /// assert_eq!(max.mul_add(three, max), Wrapping(I16F16::from_bits(!0 << 2))); /// ``` #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn mul_add(self, mul: Wrapping, add: Wrapping) -> Wrapping { Wrapping(self.0.wrapping_mul_add(mul.0, add.0)) } @@ -834,6 +839,7 @@ impl Wrapping { /// assert_eq!(Wrapping(I16F16::MAX).div_euclid(quarter), check); /// ``` #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn div_euclid(self, divisor: Wrapping) -> Wrapping { Wrapping(self.0.wrapping_div_euclid(divisor.0)) } @@ -854,6 +860,7 @@ impl Wrapping { /// assert_eq!((-num).rem_euclid(den), Wrapping(I16F16::from_num(0.5))); /// ``` #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn rem_euclid(self, divisor: Wrapping) -> Wrapping { Wrapping(self.0.rem_euclid(divisor.0)) } @@ -874,6 +881,7 @@ impl Wrapping { /// assert_eq!(min.div_euclid_int(-1), min); /// ``` #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn div_euclid_int(self, divisor: F::Bits) -> Wrapping { Wrapping(self.0.wrapping_div_euclid_int(divisor)) } @@ -893,6 +901,7 @@ impl Wrapping { /// assert_eq!((-num).rem_euclid_int(2), Wrapping(I16F16::from_num(0.5))); /// ``` #[inline] + #[must_use = "this returns the result of the operation, without modifying the original"] pub fn rem_euclid_int(self, divisor: F::Bits) -> Wrapping { Wrapping(self.0.wrapping_rem_euclid_int(divisor)) }