Skip to content

Commit

Permalink
Rollup merge of rust-lang#125455 - blyxyas:opt-clamp, r=joboet
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
matthiaskrgr authored May 24, 2024
2 parents 4649877 + d6e6918 commit 7c82490
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions library/core/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7c82490

Please sign in to comment.