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