Optimized implementations of max, min, and clamp for bool
This commit is contained in:
parent
e286f25ec0
commit
b75351e98e
1 changed files with 16 additions and 0 deletions
|
@ -1406,6 +1406,22 @@ mod impls {
|
||||||
_ => unsafe { unreachable_unchecked() },
|
_ => unsafe { unreachable_unchecked() },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn min(self, other: bool) -> bool {
|
||||||
|
self & other
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn max(self, other: bool) -> bool {
|
||||||
|
self | other
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn clamp(self, min: bool, max: bool) -> bool {
|
||||||
|
assert!(min <= max);
|
||||||
|
self.max(min).min(max)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ord_impl! { char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
|
ord_impl! { char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue