OxL Reference

method CString.asPtr

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

Example:

oxl✓ checked in CI
import c "string.h" { strlen }

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

Thread safety. the pointer is only valid while the `CString` is alive; do not share it with C code that keeps it.

Since. 1.0.0-beta

Returns

*u8

Effects

none declared (pure unless the body says otherwise)

Defined in: std/ffi/ffi.oxl:56

See also