Skip to main content

IoTypeOptional

Trait IoTypeOptional 

Source
pub unsafe trait IoTypeOptional: IoType { }
Expand description

Marker trait, companion to IoType that indicates the ability to store optional contents.

This means that zero bytes size is a valid invariant. This trait is never implemented for types implementing TrivialType because they always have fixed size, and it is not zero.

§Safety

Size 0 must be a valid state that doesn’t require any initialized memory: IoType::from_ptr(), IoType::from_mut_ptr(), IoType::try_from_ptr() and IoType::try_from_mut_ptr() must be sound to call with size of 0 and uninitialized memory behind the pointer, and must not expose that memory as initialized.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<Data> IoTypeOptional for MaybeData<Data>
where Data: TrivialType, [(); _]:,

Source§

impl<Element, const RECOMMENDED_ALLOCATION: u32> IoTypeOptional for VariableElements<Element, RECOMMENDED_ALLOCATION>
where Element: TrivialType, [(); _]:,