method isize.clamp
lo when the value is below it, hi when it is above, the value itself otherwise.
Example:
fn main() io {
let a: isize = 15
print("{a.clamp(0, 10)} {(5 as isize).clamp(0, 10)}")
}Output
10 5
pub(api) fn clamp(lo: isize, hi: isize) -> isizeComplexity. O(1).
Since. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
lo | isize |
hi | isize |
Returns
isize
Effects
none declared (pure unless the body says otherwise)
Defined in: std/core/numbers.oxl:1676