We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 235a4c0 commit 3fadbd5Copy full SHA for 3fadbd5
library/core/src/cmp.rs
@@ -1997,6 +1997,19 @@ mod impls {
1997
fn cmp(&self, other: &Self) -> Ordering {
1998
crate::intrinsics::three_way_compare(*self, *other)
1999
}
2000
+
2001
+ #[inline]
2002
+ fn clamp(self, min: Self, max: Self) -> Self
2003
+ {
2004
+ assert!(min <= max, "min > max. min = {min}, max = {max}");
2005
+ if self < min {
2006
+ min
2007
+ } else if self > max {
2008
+ max
2009
+ } else {
2010
+ self
2011
+ }
2012
2013
2014
)*)
2015
0 commit comments