Expand description
An owned slice that tries to use only one word of storage.
ThinBoxedSlice<T>
can be used in place of Box<[T]>
on the x86_64
architecture to hold ownership of a slice when it’s important to reduce
memory usage of the box itself. When the slice length is less than
0xffff
, a single word is used to encode the slice pointer and length.
When it is greater than 0xffff
, a heap allocation is used to store the
fat pointer representing the slice.
A ThinBoxedSlice<T>
is always created by converting from a Box<[T]>
.
On any architecture other than x86_64
, a ThinBoxedSlice<T>
will simply
use a Box<[T]>
internally.
§Examples
Creating a ThinBoxedSlice
:
let fat_pointer = vec![10, 20, 30].into_boxed_slice();
let thin_pointer: ThinBoxedSlice<_> = fat_pointer.into();
Structs§
- An owned slice that tries to use only one word of storage.