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()) }}")
}Вывод
[] native
pub(api) static unsafe fn fromPtr(p: *u8) -> strСложность. O(n) in the length of the C string.
С версии. 1.0.0-beta
Параметры
| Имя | Тип |
|---|---|
p | *u8 |
Возвращает
str
Эффекты
не объявлены (чистая, пока тело не говорит иное)
Определено в: std/ffi/ffi.oxl:138