Skip to main content

Module out

Module out 

Source
Expand description

Wrapper for the “out pointer” pattern.

This is functionally equivalent to &Cell<MaybeUninit<T>> except the only allowed operation is to write a T. Using MaybeUninit directly would not have been equally general; a &mut MaybeUninit<T> could never then be created from a &mut T and passed to safe code, which can safely replace it with MaybeUninit::uninit and make the existence of &mut T UB.

As for the “&Cell<...>”, this is to be slightly weaker than Rust’s normally strict requirement that &mut references are never aliased, which can typically not be assumed when getting pointers from C.

Structs§

Out
Wrapper for write-only “out pointers” that are safe to write to

Traits§

CastSlice
OutProject
Marker trait for types where it is sound to turn Out<struct { ... }> into struct { ...: Out<...> } by simply referencing fields. This is safe for any struct but must not be implemented for Deref types so that Out<&struct { ... }> is never projected in a way that adds mutability.