Struct

core::cstr::CStr

source
struct CStr { ... }

A borrowed, process-lifetime NUL-terminated string. Construction is restricted because even measuring an arbitrary pointer would be unsafe.

Methods

method from_rawsource

unsafe fn from_raw(ptr: *u8) -> CStr { ... }

The C string at ptr.

Caller: ptr addresses a NUL-terminated byte run that stays readable and unchanged for the rest of the process, as argv entries do.

method as_ptrsource

fn as_ptr(self) -> *u8 { ... }

The raw pointer, for C interfaces. It grants no safe dereference authority.

method lensource

fn len(self) -> usize { ... }

The number of bytes before the NUL. It scans for the NUL each time.

method bytessource

fn bytes(self) -> Str['static] { ... }

The bytes before the NUL, as 'static text: they stay readable and unchanged for the rest of the process, so StaticRead reads them.