method CStr.fromPtr
Copies the NUL-terminated bytes at p into a str ("" for a null pointer). The bytes should be UTF-8.
Example:
use std.ffi { CStr, null }
fn main() io {
let none_here = unsafe { CStr.fromPtr(null<u8>()) }
let s = "native".toCString()
print("[{none_here}] {unsafe { CStr.fromPtr(s.asPtr()) }}")
}Output
[] native
pub(api) static unsafe fn fromPtr(p: *u8) -> strComplexity. O(n) in the length of the C string.
Since. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
p | *u8 |
Returns
str
Effects
none declared (pure unless the body says otherwise)
Defined in: std/ffi/ffi.oxl:138