Module helpers

Module helpers 

Source
Expand description

Helpers that tend to be useful in other libraries as well.

Structs§

AllocGuard
A RAII guard that owns a single allocation and ensures it is deallocated unless explicitly released.
SliceAllocGuard
A RAII guard for a heap‐allocated slice that tracks how many elements have been initialized.

Functions§

align_up
Aligns the given value up to a non-zero alignment.
align_up_unchecked
Aligns the given value up to an alignment.
check_ptr_overlap
Checks if two pointers of to data of size sz overlap.
checked_op
Performs a checked arithmetic operation on two usizes.
checked_op_panic
Performs a checked arithmetic operation on two usizes.
checked_op_panic_const
Performs a checked arithmetic operation on two usizes.
dangling_nonnull
Returns a NonNull which has the given alignment as its address.
dangling_nonnull_for
Returns a valid, dangling NonNull for the given layout.
layout_or_sz_align
Gets either a valid layout with space for n count of T, or a raw size and alignment.
nonnull_from_ref
Converts a reference into a NonNull.
nonnull_slice_from_raw_parts
Creates a NonNull<[T]> from a pointer and a length.
nonnull_slice_len
Returns the length of a NonNull slice pointer.
ptr_max_align
Returns the maximum alignment satisfied by a non-null pointer.
slice_ptr_from_raw_parts
Creates a *mut [T] from a pointer and a length.