error unsafe-required
Операция требует блока 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#
extern c fn getpid() -> i32
fn main() {
let pid = getpid() // <- unsafe-required
}error
unsafe-required
How to fix#
extern c fn getpid() -> i32
fn pid() -> i32 {
unsafe { getpid() }
}Wrap the operation in unsafe { ... } and expose a safe function around it.