Struct array_init_cursor::Cursor[][src]

pub struct Cursor<'a, T, const N: usize> { /* fields omitted */ }
Expand description

A fixed-size cursor for initializing MaybeUninit arrays

The cursor will guarantee that all values have been initialized when the value is dropped, which means that it is safe to call MaybeUninit::assume_init().

NOTE: This guarantee only holds as long as Drop::drop() is called. If the value goes out of scope without drop being called (e.g. because of core::mem::forget()), then this guarantee no longer applies.

Implementations

Creates a new cursor.

Finishes the buffer by writing the remaining values.

This is equivalent to calling self.write::<N, 0>(value), except it is slightly more ergonomic.

Writes L values to the buffer and returns a new cursor for the remaining R values.

This function cannot compile unless L + R == N, however it will be able to pass through cargo check, since the error is not discovered by rustc until it tries to instantiate the code.

Splits the cursor in two.

This function cannot compile unless L + R == N, however it will be able to pass through cargo check, since the error is not discovered by rustc until it tries to instantiate the code.

Compile-time assertion that N == M to work-around limitations in rust generics.

This is useful if a type-signature requires the function to have a generic size argument, but you want compile-time errors when called with the wrong parameter.

Examples
fn example<const N: usize>(cursor: array_init_cursor::Cursor<'_, u8, N>) {
    let cursor: array_init_cursor::Cursor<u8, 10> = cursor.assert_size();
}

Trait Implementations

Will panic unless cursor has been completely initialized

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.