link tuple in docs

This commit is contained in:
Trevor Spiteri 2019-08-06 22:43:02 +02:00
parent 4f1a9b3bd3
commit 5bffc02836
4 changed files with 76 additions and 41 deletions

View File

@ -802,7 +802,7 @@ assert_eq!(Fix::min_value().wrapping_abs(), Fix::min_value());
comment!( comment!(
"Overflowing negation. "Overflowing negation.
Returns a tuple of the negated value and a [`bool`] indicating whether Returns a [tuple] of the negated value and a [`bool`] indicating whether
an overflow has occurred. On overflow, the wrapped value is returned. an overflow has occurred. On overflow, the wrapped value is returned.
", ",
@ -833,6 +833,7 @@ assert_eq!(Fix::from_int(5).overflowing_neg(), (Fix::from_bits(neg_five_bits), t
``` ```
[`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
[tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
"; ";
#[inline] #[inline]
pub fn overflowing_neg(self) -> ($Fixed<Frac>, bool) { pub fn overflowing_neg(self) -> ($Fixed<Frac>, bool) {
@ -844,7 +845,7 @@ assert_eq!(Fix::from_int(5).overflowing_neg(), (Fix::from_bits(neg_five_bits), t
comment!( comment!(
"Overflowing addition. "Overflowing addition.
Returns a tuple of the sum and a [`bool`] indicating whether an Returns a [tuple] of the sum and a [`bool`] indicating whether an
overflow has occurred. On overflow, the wrapped value is returned. overflow has occurred. On overflow, the wrapped value is returned.
# Examples # Examples
@ -862,6 +863,7 @@ assert_eq!(Fix::max_value().overflowing_add(one), (",
``` ```
[`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
[tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
"; ";
#[inline] #[inline]
pub fn overflowing_add(self, rhs: $Fixed<Frac>) -> ($Fixed<Frac>, bool) { pub fn overflowing_add(self, rhs: $Fixed<Frac>) -> ($Fixed<Frac>, bool) {
@ -873,7 +875,7 @@ assert_eq!(Fix::max_value().overflowing_add(one), (",
comment!( comment!(
"Overflowing subtraction. "Overflowing subtraction.
Returns a tuple of the difference and a [`bool`] indicating whether an Returns a [tuple] of the difference and a [`bool`] indicating whether an
overflow has occurred. On overflow, the wrapped value is returned. overflow has occurred. On overflow, the wrapped value is returned.
# Examples # Examples
@ -896,6 +898,7 @@ assert_eq!(Fix::from_int(0)",
``` ```
[`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
[tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
"; ";
#[inline] #[inline]
pub fn overflowing_sub(self, rhs: $Fixed<Frac>) -> ($Fixed<Frac>, bool) { pub fn overflowing_sub(self, rhs: $Fixed<Frac>) -> ($Fixed<Frac>, bool) {
@ -907,7 +910,7 @@ assert_eq!(Fix::from_int(0)",
comment!( comment!(
"Overflowing multiplication. "Overflowing multiplication.
Returns a tuple of the product and a [`bool`] indicating whether an Returns a [tuple] of the product and a [`bool`] indicating whether an
overflow has occurred. On overflow, the wrapped value is returned. overflow has occurred. On overflow, the wrapped value is returned.
# Examples # Examples
@ -922,6 +925,7 @@ assert_eq!(Fix::max_value().overflowing_mul(Fix::from_int(4)), (wrapped, true));
``` ```
[`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
[tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
"; ";
#[inline] #[inline]
pub fn overflowing_mul(self, rhs: $Fixed<Frac>) -> ($Fixed<Frac>, bool) { pub fn overflowing_mul(self, rhs: $Fixed<Frac>) -> ($Fixed<Frac>, bool) {
@ -933,7 +937,7 @@ assert_eq!(Fix::max_value().overflowing_mul(Fix::from_int(4)), (wrapped, true));
comment!( comment!(
"Overflowing division. "Overflowing division.
Returns a tuple of the quotient and a [`bool`] indicating whether an Returns a [tuple] of the quotient and a [`bool`] indicating whether an
overflow has occurred. On overflow, the wrapped value is returned. overflow has occurred. On overflow, the wrapped value is returned.
# Panics # Panics
@ -963,7 +967,7 @@ assert_eq!(Fix::max_value().overflowing_div(quarter), (wrapped, true));
comment!( comment!(
"Overflowing multiplication by an integer. "Overflowing multiplication by an integer.
Returns a tuple of the product and a [`bool`] indicating whether an Returns a [tuple] of the product and a [`bool`] indicating whether an
overflow has occurred. On overflow, the wrapped value is returned. overflow has occurred. On overflow, the wrapped value is returned.
# Examples # Examples
@ -978,6 +982,7 @@ assert_eq!(Fix::max_value().overflowing_mul_int(4), (wrapped, true));
``` ```
[`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
[tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
"; ";
#[inline] #[inline]
pub fn overflowing_mul_int(self, rhs: $Inner) -> ($Fixed<Frac>, bool) { pub fn overflowing_mul_int(self, rhs: $Inner) -> ($Fixed<Frac>, bool) {
@ -989,7 +994,7 @@ assert_eq!(Fix::max_value().overflowing_mul_int(4), (wrapped, true));
comment!( comment!(
"Overflowing division by an integer. "Overflowing division by an integer.
Returns a tuple of the quotient and ", Returns a [tuple] of the quotient and ",
if_signed_unsigned!( if_signed_unsigned!(
$Signedness, $Signedness,
"a [`bool`] indicating whether an overflow has "a [`bool`] indicating whether an overflow has
@ -1021,6 +1026,7 @@ assert_eq!(Fix::from_int(3).overflowing_div_int(2), (one_point_5, false));
"``` "```
[`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
[tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
"; ";
#[inline] #[inline]
pub fn overflowing_div_int(self, rhs: $Inner) -> ($Fixed<Frac>, bool) { pub fn overflowing_div_int(self, rhs: $Inner) -> ($Fixed<Frac>, bool) {
@ -1032,7 +1038,7 @@ assert_eq!(Fix::from_int(3).overflowing_div_int(2), (one_point_5, false));
comment!( comment!(
"Overflowing fixed-point remainder for division by an integer. "Overflowing fixed-point remainder for division by an integer.
Returns a tuple of the remainder and ", Returns a [tuple] of the remainder and ",
if_signed_unsigned!( if_signed_unsigned!(
$Signedness, $Signedness,
"a [`bool`] indicating whether an overflow has "a [`bool`] indicating whether an overflow has
@ -1063,6 +1069,7 @@ assert_eq!(Fix::from_bits(0b10101).overflowing_rem_int(8), (Fix::from_bits(0b101
"``` "```
[`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
[tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
"; ";
#[inline] #[inline]
pub fn overflowing_rem_int(self, rhs: $Inner) -> ($Fixed<Frac>, bool) { pub fn overflowing_rem_int(self, rhs: $Inner) -> ($Fixed<Frac>, bool) {
@ -1074,7 +1081,7 @@ assert_eq!(Fix::from_bits(0b10101).overflowing_rem_int(8), (Fix::from_bits(0b101
comment!( comment!(
"Overflowing shift left. "Overflowing shift left.
Returns a tuple of the shifted value and a [`bool`] indicating whether Returns a [tuple] of the shifted value and a [`bool`] indicating whether
an overflow has occurred. Overflow occurs when `rhs` ", an overflow has occurred. Overflow occurs when `rhs` ",
$s_nbits, $s_nbits,
". On overflow `rhs` is wrapped before the shift operation. ". On overflow `rhs` is wrapped before the shift operation.
@ -1092,6 +1099,7 @@ assert_eq!((Fix::from_int(1) / 2).overflowing_shl(3 + ",
``` ```
[`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
[tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
"; ";
#[inline] #[inline]
pub fn overflowing_shl(self, rhs: u32) -> ($Fixed<Frac>, bool) { pub fn overflowing_shl(self, rhs: u32) -> ($Fixed<Frac>, bool) {
@ -1103,7 +1111,7 @@ assert_eq!((Fix::from_int(1) / 2).overflowing_shl(3 + ",
comment!( comment!(
"Overflowing shift right. "Overflowing shift right.
Returns a tuple of the shifted value and a [`bool`] indicating whether Returns a [tuple] of the shifted value and a [`bool`] indicating whether
an overflow has occurred. Overflow occurs when `rhs` ", an overflow has occurred. Overflow occurs when `rhs` ",
$s_nbits, $s_nbits,
". On overflow `rhs` is wrapped before the shift operation. ". On overflow `rhs` is wrapped before the shift operation.
@ -1121,6 +1129,7 @@ assert_eq!((Fix::from_int(4)).overflowing_shr(3 + ",
``` ```
[`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
[tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
"; ";
#[inline] #[inline]
pub fn overflowing_shr(self, rhs: u32) -> ($Fixed<Frac>, bool) { pub fn overflowing_shr(self, rhs: u32) -> ($Fixed<Frac>, bool) {
@ -1134,7 +1143,7 @@ assert_eq!((Fix::from_int(4)).overflowing_shr(3 + ",
comment!( comment!(
"Overflowing absolute value. "Overflowing absolute value.
Returns a tuple of the absolute value and a [`bool`] indicating Returns a [tuple] of the absolute value and a [`bool`] indicating
whether an overflow has occurred. On overflow, the wrapped value is whether an overflow has occurred. On overflow, the wrapped value is
returned. returned.
@ -1151,6 +1160,7 @@ assert_eq!(Fix::min_value().overflowing_abs(), (Fix::min_value(), true));
``` ```
[`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
[tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
"; ";
#[inline] #[inline]
pub fn overflowing_abs(self) -> ($Fixed<Frac>, bool) { pub fn overflowing_abs(self) -> ($Fixed<Frac>, bool) {

View File

@ -1042,7 +1042,7 @@ assert_eq!(Fix::wrapping_from_float(large), wrapped);
"Creates a fixed-point number from another fixed-point "Creates a fixed-point number from another fixed-point
number. number.
Returns a tuple of the fixed-point number and a [`bool`] indicating Returns a [tuple] of the fixed-point number and a [`bool`] indicating
whether an overflow has occurred. On overflow, the wrapped value is whether an overflow has occurred. On overflow, the wrapped value is
returned. returned.
@ -1074,6 +1074,7 @@ assert_eq!(Dst::overflowing_from_fixed(too_large), (wrapped, true));
``` ```
[`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
[tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
"; ";
#[inline] #[inline]
pub fn overflowing_from_fixed<F>(val: F) -> ($Fixed<Frac>, bool) pub fn overflowing_from_fixed<F>(val: F) -> ($Fixed<Frac>, bool)
@ -1088,7 +1089,7 @@ assert_eq!(Dst::overflowing_from_fixed(too_large), (wrapped, true));
"Converts a fixed-point number to another fixed-point "Converts a fixed-point number to another fixed-point
number. number.
Returns a tuple of the fixed-point number and a [`bool`] indicating Returns a [tuple] of the fixed-point number and a [`bool`] indicating
whether an overflow has occurred. On overflow, the wrapped value is whether an overflow has occurred. On overflow, the wrapped value is
returned. returned.
@ -1124,7 +1125,7 @@ assert_eq!(Src::max_value().overflowing_to_fixed::<TooFewIntBits>(), (wrapped, t
comment!( comment!(
"Creates a fixed-point number from an integer. "Creates a fixed-point number from an integer.
Returns a tuple of the fixed-point number and a [`bool`] indicating Returns a [tuple] of the fixed-point number and a [`bool`] indicating
whether an overflow has occurred. On overflow, the wrapped value is whether an overflow has occurred. On overflow, the wrapped value is
returned. returned.
@ -1166,6 +1167,7 @@ assert_eq!(Fix::overflowing_from_int(large), (wrapped, true));
[`u64`]: https://doc.rust-lang.org/nightly/std/primitive.u64.html [`u64`]: https://doc.rust-lang.org/nightly/std/primitive.u64.html
[`u8`]: https://doc.rust-lang.org/nightly/std/primitive.u8.html [`u8`]: https://doc.rust-lang.org/nightly/std/primitive.u8.html
[`usize`]: https://doc.rust-lang.org/nightly/std/primitive.usize.html [`usize`]: https://doc.rust-lang.org/nightly/std/primitive.usize.html
[tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
"; ";
#[inline] #[inline]
pub fn overflowing_from_int<I>(val: I) -> ($Fixed<Frac>, bool) pub fn overflowing_from_int<I>(val: I) -> ($Fixed<Frac>, bool)
@ -1179,7 +1181,7 @@ assert_eq!(Fix::overflowing_from_int(large), (wrapped, true));
comment!( comment!(
"Converts a fixed-point number to an integer. "Converts a fixed-point number to an integer.
Returns a tuple of the integer and a [`bool`] indicating whether an Returns a [tuple] of the integer and a [`bool`] indicating whether an
overflow has occurred. On overflow, the wrapped value is returned. overflow has occurred. On overflow, the wrapped value is returned.
The integer can be of type [`i8`], [`i16`], [`i32`], [`i64`], The integer can be of type [`i8`], [`i16`], [`i32`], [`i64`],
@ -1234,6 +1236,7 @@ assert_eq!(does_not_fit.overflowing_to_int::<",
[`u64`]: https://doc.rust-lang.org/nightly/std/primitive.u64.html [`u64`]: https://doc.rust-lang.org/nightly/std/primitive.u64.html
[`u8`]: https://doc.rust-lang.org/nightly/std/primitive.u8.html [`u8`]: https://doc.rust-lang.org/nightly/std/primitive.u8.html
[`usize`]: https://doc.rust-lang.org/nightly/std/primitive.usize.html [`usize`]: https://doc.rust-lang.org/nightly/std/primitive.usize.html
[tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
"; ";
#[inline] #[inline]
pub fn overflowing_to_int<I>(self) -> (I, bool) pub fn overflowing_to_int<I>(self) -> (I, bool)
@ -1248,7 +1251,7 @@ assert_eq!(does_not_fit.overflowing_to_int::<",
"Creates a fixed-point number from a floating-point "Creates a fixed-point number from a floating-point
number. number.
Returns a tuple of the fixed-point number and a [`bool`] indicating whether Returns a [tuple] of the fixed-point number and a [`bool`] indicating whether
an overflow has occurred. On overflow, the wrapped value is returned. an overflow has occurred. On overflow, the wrapped value is returned.
The floating-point value can be of type [`f32`] or [`f64`]. The floating-point value can be of type [`f32`] or [`f64`].
@ -1290,6 +1293,7 @@ assert_eq!(Fix::overflowing_from_float(large), (wrapped, true));
[`f32`]: https://doc.rust-lang.org/nightly/std/primitive.f32.html [`f32`]: https://doc.rust-lang.org/nightly/std/primitive.f32.html
[`f64`]: https://doc.rust-lang.org/nightly/std/primitive.f64.html [`f64`]: https://doc.rust-lang.org/nightly/std/primitive.f64.html
[finite]: https://doc.rust-lang.org/nightly/std/primitive.f64.html#method.is_finite [finite]: https://doc.rust-lang.org/nightly/std/primitive.f64.html#method.is_finite
[tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
"; ";
#[inline] #[inline]
pub fn overflowing_from_float<F>(val: F) -> ($Fixed<Frac>, bool) pub fn overflowing_from_float<F>(val: F) -> ($Fixed<Frac>, bool)

View File

@ -532,7 +532,7 @@ assert_eq!(two_half.wrapping_round(), Fix::from_int(3));
comment!( comment!(
"Overflowing ceil. Rounds to the next integer towards +∞. "Overflowing ceil. Rounds to the next integer towards +∞.
Returns a tuple of the fixed-point number and a [`bool`], indicating Returns a [tuple] of the fixed-point number and a [`bool`], indicating
whether an overflow has occurred. On overflow, the wrapped value is whether an overflow has occurred. On overflow, the wrapped value is
returned. returned.
@ -554,6 +554,7 @@ assert_eq!(two_half.overflowing_ceil(), (Fix::from_int(3), false));
``` ```
[`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
[tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
"; ";
#[inline] #[inline]
pub fn overflowing_ceil(self) -> ($Fixed<Frac>, bool) { pub fn overflowing_ceil(self) -> ($Fixed<Frac>, bool) {
@ -579,15 +580,14 @@ assert_eq!(two_half.overflowing_ceil(), (Fix::from_int(3), false));
comment!( comment!(
"Overflowing floor. Rounds to the next integer towards −∞. "Overflowing floor. Rounds to the next integer towards −∞.
Returns a [tuple] of the fixed-point number and
", ",
if_signed_unsigned!( if_signed_unsigned!(
$Signedness, $Signedness,
"Returns a tuple of the fixed-point number and a "a [`bool`], indicating whether an overflow has
[`bool`], indicating whether an overflow has occurred. On overflow, occurred. On overflow, the wrapped value isreturned. Overflow can only
the wrapped value isreturned. Overflow can only occur when there are occur when there are zero integer bits.",
zero integer bits.", "[`false`][`bool`].",
"Returns a tuple of the fixed-point number and
[`false`][`bool`].",
), ),
" "
@ -614,6 +614,7 @@ assert_eq!(AllFrac::min_value().overflowing_floor(), (AllFrac::from_int(0), true
"``` "```
[`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
[tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
"; ";
#[inline] #[inline]
pub fn overflowing_floor(self) -> ($Fixed<Frac>, bool) { pub fn overflowing_floor(self) -> ($Fixed<Frac>, bool) {
@ -632,7 +633,7 @@ assert_eq!(AllFrac::min_value().overflowing_floor(), (AllFrac::from_int(0), true
"Overflowing round. Rounds to the next integer to the "Overflowing round. Rounds to the next integer to the
nearest, with ties rounded away from zero. nearest, with ties rounded away from zero.
Returns a tuple of the fixed-point number and a [`bool`] indicating Returns a [tuple] of the fixed-point number and a [`bool`] indicating
whether an overflow has occurred. On overflow, the wrapped value is whether an overflow has occurred. On overflow, the wrapped value is
returned. returned.
@ -654,6 +655,7 @@ assert_eq!(two_half.overflowing_round(), (Fix::from_int(3), false));
``` ```
[`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
[tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
"; ";
#[inline] #[inline]
pub fn overflowing_round(self) -> ($Fixed<Frac>, bool) { pub fn overflowing_round(self) -> ($Fixed<Frac>, bool) {

View File

@ -110,30 +110,33 @@ pub trait Fixed: Copy + FromFixed + ToFixed + sealed::Fixed {
/// Overflowing ceil. Rounds to the next integer towards +∞. /// Overflowing ceil. Rounds to the next integer towards +∞.
/// ///
/// Returns a tuple of the fixed-point number and a [`bool`], /// Returns a [tuple] of the fixed-point number 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.
/// ///
/// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html /// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
/// [tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
fn overflowing_ceil(self) -> (Self, bool); fn overflowing_ceil(self) -> (Self, bool);
/// Overflowing floor. Rounds to the next integer towards −∞. /// Overflowing floor. Rounds to the next integer towards −∞.
/// ///
/// Returns a tuple of the fixed-point number and a [`bool`], /// Returns a [tuple] of the fixed-point number 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.
/// ///
/// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html /// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
/// [tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
fn overflowing_floor(self) -> (Self, bool); fn overflowing_floor(self) -> (Self, bool);
/// Overflowing round. Rounds to the next integer to the nearest, /// Overflowing round. Rounds to the next integer to the nearest,
/// with ties rounded away from zero. /// with ties rounded away from zero.
/// ///
/// Returns a tuple of the fixed-point number and a [`bool`], /// Returns a [tuple] of the fixed-point number 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.
/// ///
/// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html /// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
/// [tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
fn overflowing_round(self) -> (Self, bool); fn overflowing_round(self) -> (Self, bool);
/// Returns the number of ones in the binary representation. /// Returns the number of ones in the binary representation.
@ -285,43 +288,47 @@ pub trait Fixed: Copy + FromFixed + ToFixed + sealed::Fixed {
/// Overflowing negation. /// Overflowing negation.
/// ///
/// Returns a tuple of the negated value and a [`bool`], /// Returns a [tuple] of the negated 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.
/// ///
/// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html /// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
/// [tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
fn overflowing_neg(self) -> (Self, bool); fn overflowing_neg(self) -> (Self, bool);
/// Overflowing addition. /// Overflowing addition.
/// ///
/// 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.
/// ///
/// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html /// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
/// [tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
fn overflowing_add(self, rhs: Self) -> (Self, bool); fn overflowing_add(self, rhs: Self) -> (Self, bool);
/// Overflowing subtraction. /// Overflowing subtraction.
/// ///
/// 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.
/// ///
/// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html /// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
/// [tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
fn overflowing_sub(self, rhs: Self) -> (Self, bool); fn overflowing_sub(self, rhs: Self) -> (Self, bool);
/// Overflowing multiplication. /// Overflowing multiplication.
/// ///
/// 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.
/// ///
/// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html /// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
/// [tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
fn overflowing_mul(self, rhs: Self) -> (Self, bool); fn overflowing_mul(self, rhs: Self) -> (Self, bool);
/// Overflowing division. /// Overflowing division.
/// ///
/// Returns a tuple of the quotient and a [`bool`], indicating /// Returns a [tuple] of the quotient 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.
/// ///
@ -330,20 +337,22 @@ pub trait Fixed: Copy + FromFixed + ToFixed + sealed::Fixed {
/// Panics if the divisor is zero. /// Panics if the divisor is zero.
/// ///
/// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html /// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
/// [tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
fn overflowing_div(self, rhs: Self) -> (Self, bool); fn overflowing_div(self, rhs: Self) -> (Self, bool);
/// Overflowing multiplication by an integer. /// Overflowing multiplication by an integer.
/// ///
/// 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.
/// ///
/// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html /// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
/// [tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
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.
/// ///
/// Returns a tuple of the quotient and a [`bool`], indicating /// Returns a [tuple] of the quotient 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.
/// ///
@ -352,11 +361,12 @@ pub trait Fixed: Copy + FromFixed + ToFixed + sealed::Fixed {
/// Panics if the divisor is zero. /// Panics if the divisor is zero.
/// ///
/// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html /// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
/// [tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
fn overflowing_div_int(self, rhs: Self::Bits) -> (Self, bool); fn overflowing_div_int(self, rhs: Self::Bits) -> (Self, bool);
/// Overflowing fixed-point remainder for division by an integer. /// Overflowing fixed-point remainder for division by an integer.
/// ///
/// Returns a tuple of the remainder and a [`bool`], indicating /// Returns a [tuple] of the remainder 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. Overflow can only occur when dividing the /// value is returned. Overflow can only occur when dividing the
/// minimum value by 1. /// minimum value by 1.
@ -366,24 +376,27 @@ pub trait Fixed: Copy + FromFixed + ToFixed + sealed::Fixed {
/// Panics if the divisor is zero. /// Panics if the divisor is zero.
/// ///
/// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html /// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
/// [tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
fn overflowing_rem_int(self, rhs: Self::Bits) -> (Self, bool); fn overflowing_rem_int(self, rhs: Self::Bits) -> (Self, bool);
/// Overflowing shift left. /// Overflowing shift left.
/// ///
/// 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.
/// ///
/// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html /// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
/// [tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
fn overflowing_shl(self, rhs: u32) -> (Self, bool); fn overflowing_shl(self, rhs: u32) -> (Self, bool);
/// Overflowing shift right. /// Overflowing shift right.
/// ///
/// 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.
/// ///
/// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html /// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
/// [tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
fn overflowing_shr(self, rhs: u32) -> (Self, bool); fn overflowing_shr(self, rhs: u32) -> (Self, bool);
} }
@ -428,21 +441,24 @@ pub trait FixedSigned: Fixed {
/// Overflowing absolute value. /// Overflowing absolute value.
/// ///
/// Returns a tuple of the fixed-point number and a [`bool`], /// Returns a [tuple] of the fixed-point number 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.
/// ///
/// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html /// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
/// [tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
fn overflowing_abs(self) -> (Self, bool); fn overflowing_abs(self) -> (Self, bool);
/// Returns [`true`][`bool`] if the number is > 0. /// Returns [`true`][`bool`] if the number is > 0.
/// ///
/// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html /// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
/// [tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
fn is_positive(self) -> bool; fn is_positive(self) -> bool;
/// Returns [`true`][`bool`] if the number is < 0. /// Returns [`true`][`bool`] if the number is < 0.
/// ///
/// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html /// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
/// [tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
fn is_negative(self) -> bool; fn is_negative(self) -> bool;
} }
@ -452,6 +468,7 @@ pub trait FixedUnsigned: Fixed {
/// 2<sup><i>k</i></sup> for some integer <i>k</i>. /// 2<sup><i>k</i></sup> for some integer <i>k</i>.
/// ///
/// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html /// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
/// [tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
fn is_power_of_two(self) -> bool; fn is_power_of_two(self) -> bool;
/// Returns the smallest power of two ≥ `self`. /// Returns the smallest power of two ≥ `self`.
@ -584,13 +601,14 @@ pub trait FromFixed {
/// Converts from a fixed-point number. /// Converts from a fixed-point number.
/// ///
/// Returns a tuple of the value and a [`bool`] indicating whether /// Returns a [tuple] of the value 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.
/// ///
/// Any extra fractional bits are truncated. /// Any extra fractional bits are truncated.
/// ///
/// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html /// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
/// [tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
fn overflowing_from_fixed<F>(val: F) -> (Self, bool) fn overflowing_from_fixed<F>(val: F) -> (Self, bool)
where where
F: sealed::Fixed, F: sealed::Fixed,
@ -663,13 +681,14 @@ pub trait ToFixed {
/// Converts from a fixed-point number. /// Converts from a fixed-point number.
/// ///
/// Returns a tuple of the fixed-point number and a [`bool`] /// Returns a [tuple] of the fixed-point number 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.
/// ///
/// Any extra fractional bits are truncated. /// Any extra fractional bits are truncated.
/// ///
/// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html /// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
/// [tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
fn overflowing_to_fixed<F>(self) -> (F, bool) fn overflowing_to_fixed<F>(self) -> (F, bool)
where where
F: sealed::Fixed; F: sealed::Fixed;