Feature gate: #[feature(num_midpoint)], #[feature(num_midpoint_signed)] and #![feature(const_num_midpoint)]
This is a tracking issue for the midpoint function to {u,i}{8,16,32,64,128,size}, NonZeroU{8,16,32,64,size} and f{32,64}.
The midpoint function calculates the middle point of lhs and rhs.
Public API
impl {u,i}{8,16,32,64,128,size} {
pub const fn midpoint(self, rhs: Self) -> Self;
}
impl NonZeroU{8,16,32,64,size} {
pub const fn midpoint(self, rhs: Self) -> Self;
}
impl f{32,64} {
pub const fn midpoint(self, rhs: Self) -> Self;
}
Steps / History
Unresolved Questions
Feature gate:
#[feature(num_midpoint)],#[feature(num_midpoint_signed)]and#![feature(const_num_midpoint)]This is a tracking issue for the midpoint function to
{u,i}{8,16,32,64,128,size},NonZeroU{8,16,32,64,size}andf{32,64}.The midpoint function calculates the middle point of
lhsandrhs.Public API
Steps / History
num_midpointfeature #131784 (comment)num_midpoint_signedfeature #134340num_midpointfeature #131784num_midpoint_signedfeature #134340Unresolved Questions
negative infinityzero): Add midpoint function for all integers and floating numbers #92048 (comment)iN::midpoint#132191 we round towards zero, as to be consistent with the obvious impl(a + b) / 2.Whether it's commutative (some people wantmidpoint(a, b) == midpoint(b, a), but others want a non-commutative definition)Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩