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

error unsafe-required

error Стандарт: [§7.5]

Операция требует блока unsafe.

What it means#

Raw pointers and their dereference, FFI calls, T.unchecked(...) for refined types, and transmute are allowed only inside unsafe { ... } or an unsafe fn (§7.5, §16.1).

Example#

oxl✓ проверяется в CI
extern c fn getpid() -> i32

fn main() {
  let pid = getpid()      // <- unsafe-required
}
error
unsafe-required

How to fix#

oxl✓ проверяется в CI
extern c fn getpid() -> i32

fn pid() -> i32 {
  unsafe { getpid() }
}

Wrap the operation in unsafe { ... } and expose a safe function around it.

See also#

OxL 1.0.0-beta · Версия документации 1.0.0-beta© OxwaldLink · сгенерировано из Стандарта, исходников std и руководства