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

method CString.asPtr

Pointer to the first byte; valid while the CString is alive.

Example:

oxl✓ проверяется в CI
import c "string.h" { strlen }

fn main() io {
  let c = "hello".toCString()
  let n: usize = unsafe { strlen(c.asPtr()) }
  print("{n}")
}
Вывод
5
pub(api) fn asPtr() -> *u8

Потокобезопасность. the pointer is only valid while the `CString` is alive; do not share it with C code that keeps it.

С версии. 1.0.0-beta

Возвращает

*u8

Эффекты

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

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

См. также