pub trait ExtendInit {
type Elem;
// Required method
fn extend_init<F: Fn(&mut [MaybeUninit<Self::Elem>]) -> &[Self::Elem]>(
&mut self,
f: F,
);
}Expand description
Extend a buffer by incrementally initializing spare capacity.
This is implemented for Vec<T>, where it provides a safe API to
initialize the spare capacity returned by
spare_capacity_mut.
Required Associated Types§
Required Methods§
Sourcefn extend_init<F: Fn(&mut [MaybeUninit<Self::Elem>]) -> &[Self::Elem]>(
&mut self,
f: F,
)
fn extend_init<F: Fn(&mut [MaybeUninit<Self::Elem>]) -> &[Self::Elem]>( &mut self, f: F, )
Extend the buffer by initializing a portion of the buffer’s spare capacity.
The function f is passed the uninitialized portion of the buffer and
should return the portion that it has initialized. extend_init can
be called many times, until the entire buffer has been initialized.
§Panics
Panics if f returns a slice that is not a prefix of the slice that
was passed to it.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".