Skip to content

Commit 35db072

Browse files
authored
Unrolled build for rust-lang#140075
Rollup merge of rust-lang#140075 - Urgau:midpoint-average, r=tgross35 Mention average in midpoint documentations Added a mention to "average" in midpoint documentations and as well as some `#[doc(alias = "average")]`[^1]. This is done to improve the discoverability of the function. [^1]: https://docs.rs/num-integer/latest/num_integer/trait.Average.html#tymethod.average_floor
2 parents dc8fe1f + e88b289 commit 35db072

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
@@ -804,7 +804,7 @@ impl f128 {
804804
}
805805
}
806806

807-
/// Calculates the middle point of `self` and `rhs`.
807+
/// Calculates the midpoint (average) between `self` and `rhs`.
808808
///
809809
/// This returns NaN when *either* argument is NaN or if a combination of
810810
/// +inf and -inf is provided as arguments.
@@ -821,6 +821,7 @@ impl f128 {
821821
/// # }
822822
/// ```
823823
#[inline]
824+
#[doc(alias = "average")]
824825
#[unstable(feature = "f128", issue = "116909")]
825826
#[rustc_const_unstable(feature = "f128", issue = "116909")]
826827
pub const fn midpoint(self, other: f128) -> f128 {

library/core/src/num/f16.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ impl f16 {
792792
}
793793
}
794794

795-
/// Calculates the middle point of `self` and `rhs`.
795+
/// Calculates the midpoint (average) between `self` and `rhs`.
796796
///
797797
/// This returns NaN when *either* argument is NaN or if a combination of
798798
/// +inf and -inf is provided as arguments.
@@ -808,6 +808,7 @@ impl f16 {
808808
/// # }
809809
/// ```
810810
#[inline]
811+
#[doc(alias = "average")]
811812
#[unstable(feature = "f16", issue = "116909")]
812813
#[rustc_const_unstable(feature = "f16", issue = "116909")]
813814
pub const fn midpoint(self, other: f16) -> f16 {

library/core/src/num/f32.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@ impl f32 {
986986
}
987987
}
988988

989-
/// Calculates the middle point of `self` and `rhs`.
989+
/// Calculates the midpoint (average) between `self` and `rhs`.
990990
///
991991
/// This returns NaN when *either* argument is NaN or if a combination of
992992
/// +inf and -inf is provided as arguments.
@@ -998,6 +998,7 @@ impl f32 {
998998
/// assert_eq!((-5.5f32).midpoint(8.0), 1.25);
999999
/// ```
10001000
#[inline]
1001+
#[doc(alias = "average")]
10011002
#[stable(feature = "num_midpoint", since = "1.85.0")]
10021003
#[rustc_const_stable(feature = "num_midpoint", since = "1.85.0")]
10031004
pub const fn midpoint(self, other: f32) -> f32 {

library/core/src/num/f64.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ impl f64 {
10041004
}
10051005
}
10061006

1007-
/// Calculates the middle point of `self` and `rhs`.
1007+
/// Calculates the midpoint (average) between `self` and `rhs`.
10081008
///
10091009
/// This returns NaN when *either* argument is NaN or if a combination of
10101010
/// +inf and -inf is provided as arguments.
@@ -1016,6 +1016,7 @@ impl f64 {
10161016
/// assert_eq!((-5.5f64).midpoint(8.0), 1.25);
10171017
/// ```
10181018
#[inline]
1019+
#[doc(alias = "average")]
10191020
#[stable(feature = "num_midpoint", since = "1.85.0")]
10201021
#[rustc_const_stable(feature = "num_midpoint", since = "1.85.0")]
10211022
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)