OxL Справочник OxL
РусскийEnglish

method u8.wrap

x.wrap<U>(): converts to the numeric type U; an integer that does not fit wraps around (keeps the low bits), a float is truncated toward zero (§3.1).

Example:

oxl✓ проверяется в CI
fn main() io {
  let small: u8 = 100
  let other: u8 = 200
  let x: i8 = small.wrap<i8>()
  let y: i8 = other.wrap<i8>()
  print("{x} {y}")
}
Вывод
100 -56
pub(api) fn wrap<U>() -> U

Сложность. O(1).

С версии. 1.0.0-beta

Возвращает

U

Эффекты

не объявлены (чистая, пока тело не говорит иное)

Определено в: std/core/numbers.oxl:3189

См. также