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

data CStr

Namespace of helpers for reading C strings.

Example:

oxl✓ проверяется в CI
use std.ffi { CStr }

import c "string.h" { strdup }
import c "stdlib.h" { free }

fn main() io {
  let c = "copy me".toCString()
  unsafe {
    let d = strdup(c.asPtr())
    print(CStr.fromPtr(d))
    free(d.cast<u8>())
  }
}
Вывод
copy me
pub(api) data CStr

С версии. 1.0.0-beta

Методы

fromPtr(p: *u8) -> str
Copies the NUL-terminated bytes at p into a str ("" for a null pointer).

Определено в: std/ffi/ffi.oxl:118

См. также