Skip to content

Commit 9b731ae

Browse files
committed
Mention average in midpoint documentations
1 parent 191df20 commit 9b731ae

File tree

6 files changed

+25
-9
lines changed

6 files changed

+25
-9
lines changed

library/core/src/num/f128.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ impl f128 {
801801
}
802802
}
803803

804-
/// Calculates the middle point of `self` and `rhs`.
804+
/// Calculates the midpoint/average between `self` and `rhs`.
805805
///
806806
/// This returns NaN when *either* argument is NaN or if a combination of
807807
/// +inf and -inf is provided as arguments.
@@ -818,6 +818,7 @@ impl f128 {
818818
/// # }
819819
/// ```
820820
#[inline]
821+
#[doc(alias = "average")]
821822
#[unstable(feature = "f128", issue = "116909")]
822823
#[rustc_const_unstable(feature = "f128", issue = "116909")]
823824
pub const fn midpoint(self, other: f128) -> f128 {

library/core/src/num/f16.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ impl f16 {
789789
}
790790
}
791791

792-
/// Calculates the middle point of `self` and `rhs`.
792+
/// Calculates the midpoint/average between `self` and `rhs`.
793793
///
794794
/// This returns NaN when *either* argument is NaN or if a combination of
795795
/// +inf and -inf is provided as arguments.
@@ -805,6 +805,7 @@ impl f16 {
805805
/// # }
806806
/// ```
807807
#[inline]
808+
#[doc(alias = "average")]
808809
#[unstable(feature = "f16", issue = "116909")]
809810
#[rustc_const_unstable(feature = "f16", issue = "116909")]
810811
pub const fn midpoint(self, other: f16) -> f16 {

library/core/src/num/f32.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ impl f32 {
983983
}
984984
}
985985

986-
/// Calculates the middle point of `self` and `rhs`.
986+
/// Calculates the midpoint/average between `self` and `rhs`.
987987
///
988988
/// This returns NaN when *either* argument is NaN or if a combination of
989989
/// +inf and -inf is provided as arguments.
@@ -995,6 +995,7 @@ impl f32 {
995995
/// assert_eq!((-5.5f32).midpoint(8.0), 1.25);
996996
/// ```
997997
#[inline]
998+
#[doc(alias = "average")]
998999
#[stable(feature = "num_midpoint", since = "1.85.0")]
9991000
#[rustc_const_stable(feature = "num_midpoint", since = "1.85.0")]
10001001
pub const fn midpoint(self, other: f32) -> f32 {

library/core/src/num/f64.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ impl f64 {
10011001
}
10021002
}
10031003

1004-
/// Calculates the middle point of `self` and `rhs`.
1004+
/// Calculates the midpoint/average between `self` and `rhs`.
10051005
///
10061006
/// This returns NaN when *either* argument is NaN or if a combination of
10071007
/// +inf and -inf is provided as arguments.
@@ -1013,6 +1013,7 @@ impl f64 {
10131013
/// assert_eq!((-5.5f64).midpoint(8.0), 1.25);
10141014
/// ```
10151015
#[inline]
1016+
#[doc(alias = "average")]
10161017
#[stable(feature = "num_midpoint", since = "1.85.0")]
10171018
#[rustc_const_stable(feature = "num_midpoint", since = "1.85.0")]
10181019
pub const fn midpoint(self, other: f64) -> f64 {

library/core/src/num/mod.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ depending on the target pointer size.
130130

131131
macro_rules! midpoint_impl {
132132
($SelfT:ty, unsigned) => {
133-
/// Calculates the middle point of `self` and `rhs`.
133+
/// Calculates the midpoint/average between `self` and `rhs`.
134134
///
135135
/// `midpoint(a, b)` is `(a + b) / 2` as if it were performed in a
136136
/// sufficiently-large unsigned integral type. This implies that the result is
@@ -146,6 +146,8 @@ macro_rules! midpoint_impl {
146146
#[rustc_const_stable(feature = "num_midpoint", since = "1.85.0")]
147147
#[must_use = "this returns the result of the operation, \
148148
without modifying the original"]
149+
#[doc(alias = "average_floor")]
150+
#[doc(alias = "average")]
149151
#[inline]
150152
pub const fn midpoint(self, rhs: $SelfT) -> $SelfT {
151153
// Use the well known branchless algorithm from Hacker's Delight to compute
@@ -154,7 +156,7 @@ macro_rules! midpoint_impl {
154156
}
155157
};
156158
($SelfT:ty, signed) => {
157-
/// Calculates the middle point of `self` and `rhs`.
159+
/// Calculates the midpoint/average between `self` and `rhs`.
158160
///
159161
/// `midpoint(a, b)` is `(a + b) / 2` as if it were performed in a
160162
/// sufficiently-large signed integral type. This implies that the result is
@@ -173,6 +175,9 @@ macro_rules! midpoint_impl {
173175
#[rustc_const_stable(feature = "num_midpoint_signed", since = "1.87.0")]
174176
#[must_use = "this returns the result of the operation, \
175177
without modifying the original"]
178+
#[doc(alias = "average_floor")]
179+
#[doc(alias = "average_ceil")]
180+
#[doc(alias = "average")]
176181
#[inline]
177182
pub const fn midpoint(self, rhs: Self) -> Self {
178183
// Use the well known branchless algorithm from Hacker's Delight to compute
@@ -184,7 +189,7 @@ macro_rules! midpoint_impl {
184189
}
185190
};
186191
($SelfT:ty, $WideT:ty, unsigned) => {
187-
/// Calculates the middle point of `self` and `rhs`.
192+
/// Calculates the midpoint/average between `self` and `rhs`.
188193
///
189194
/// `midpoint(a, b)` is `(a + b) / 2` as if it were performed in a
190195
/// sufficiently-large unsigned integral type. This implies that the result is
@@ -200,13 +205,15 @@ macro_rules! midpoint_impl {
200205
#[rustc_const_stable(feature = "num_midpoint", since = "1.85.0")]
201206
#[must_use = "this returns the result of the operation, \
202207
without modifying the original"]
208+
#[doc(alias = "average_floor")]
209+
#[doc(alias = "average")]
203210
#[inline]
204211
pub const fn midpoint(self, rhs: $SelfT) -> $SelfT {
205212
((self as $WideT + rhs as $WideT) / 2) as $SelfT
206213
}
207214
};
208215
($SelfT:ty, $WideT:ty, signed) => {
209-
/// Calculates the middle point of `self` and `rhs`.
216+
/// Calculates the midpoint/average between `self` and `rhs`.
210217
///
211218
/// `midpoint(a, b)` is `(a + b) / 2` as if it were performed in a
212219
/// sufficiently-large signed integral type. This implies that the result is
@@ -225,6 +232,9 @@ macro_rules! midpoint_impl {
225232
#[rustc_const_stable(feature = "num_midpoint_signed", since = "1.87.0")]
226233
#[must_use = "this returns the result of the operation, \
227234
without modifying the original"]
235+
#[doc(alias = "average_floor")]
236+
#[doc(alias = "average_ceil")]
237+
#[doc(alias = "average")]
228238
#[inline]
229239
pub const fn midpoint(self, rhs: $SelfT) -> $SelfT {
230240
((self as $WideT + rhs as $WideT) / 2) as $SelfT

library/core/src/num/nonzero.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1589,7 +1589,7 @@ macro_rules! nonzero_integer_signedness_dependent_methods {
15891589
super::int_log10::$Int(self.get())
15901590
}
15911591

1592-
/// Calculates the middle point of `self` and `rhs`.
1592+
/// Calculates the midpoint/average between `self` and `rhs`.
15931593
///
15941594
/// `midpoint(a, b)` is `(a + b) >> 1` as if it were performed in a
15951595
/// sufficiently-large signed integral type. This implies that the result is
@@ -1615,6 +1615,8 @@ macro_rules! nonzero_integer_signedness_dependent_methods {
16151615
#[rustc_const_stable(feature = "num_midpoint", since = "1.85.0")]
16161616
#[must_use = "this returns the result of the operation, \
16171617
without modifying the original"]
1618+
#[doc(alias = "average_floor")]
1619+
#[doc(alias = "average")]
16181620
#[inline]
16191621
pub const fn midpoint(self, rhs: Self) -> Self {
16201622
// SAFETY: The only way to get `0` with midpoint is to have two opposite or

0 commit comments

Comments
 (0)