Add Option::as_slice
(_mut
)
This adds the following functions: * `Option<T>::as_slice(&self) -> &[T]` * `Option<T>::as_slice_mut(&mut self) -> &[T]` The `as_slice` and `as_slice_mut` functions benefit from an optimization that makes them completely branch-free. Note that the optimization's soundness hinges on the fact that either the niche optimization makes the offset of the `Some(_)` contents zero or the mempory layout of `Option<T>` is equal to that of `Option<MaybeUninit<T>>`.
This commit is contained in:
parent
bd4a96a12d
commit
41da875fae
3 changed files with 148 additions and 0 deletions
|
@ -134,6 +134,7 @@
|
|||
#![feature(const_option)]
|
||||
#![feature(const_option_ext)]
|
||||
#![feature(const_pin)]
|
||||
#![feature(const_pointer_byte_offsets)]
|
||||
#![feature(const_pointer_is_aligned)]
|
||||
#![feature(const_ptr_sub_ptr)]
|
||||
#![feature(const_replace)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue