method List.asPtr
Pointer to the elements (valid until the list grows or is dropped). Writing through it is for FFI
buffers: List<u8> of the needed length filled with zeros, then p.write(..) / a C function fills it.
Example:
use std.ffi { zeroBytes }
import c "string.h" { memset }
fn main() io {
var buf = zeroBytes(4)
unsafe { memset(buf.asPtr(), 7, 4) }
print("{buf}")
}Вывод
[7, 7, 7, 7]
pub(api) fn asPtr() -> *var TПотокобезопасность. the pointer is valid only until the list grows or is dropped; do not use it from another task while the list changes.
С версии. 1.0.0-beta
Возвращает
*var T
Эффекты
не объявлены (чистая, пока тело не говорит иное)
Определено в: std/ffi/ffi.oxl:162