mirror of https://github.com/rust-lang/rust.git
Rollup merge of #125455 - blyxyas:opt-clamp, r=joboet
Make `clamp` inline Context: rust-lang/rust-clippy#12826 This results in slightly more optimized assembly. (And most important, it's now less than lines than just manually clamping a value)
This commit is contained in:
commit
268657b40b
|
@ -898,6 +898,7 @@ pub trait Ord: Eq + PartialOrd<Self> {
|
|||
/// assert_eq!(2.clamp(-2, 1), 1);
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[inline]
|
||||
#[stable(feature = "clamp", since = "1.50.0")]
|
||||
fn clamp(self, min: Self, max: Self) -> Self
|
||||
where
|
||||
|
|
Loading…
Reference in New Issue