pub struct NONE<T>(/* private fields */);
Expand description
Usable to do [None::<T>; LEN]
when T
is non-Copy
.
As of Rust 1.65.0, [None::<T>; LEN]
is not valid for non-Copy
types,
but [CONST; LEN]
does work, like in the example below.
§Example
use konst::option::NONE;
use std::mem::{self, MaybeUninit};
const TEN: [Option<String>; 10] = [NONE::V; 10];
let ten = [NONE::<String>::V; 10];
// the `vec` macro only needs `Option<String>` to be clonable, not Copy.
assert_eq!(vec![None::<String>; 10], TEN);
assert_eq!(vec![None::<String>; 10], ten);
Implementations§
Auto Trait Implementations§
impl<T> Freeze for NONE<T>
impl<T> RefUnwindSafe for NONE<T>where
T: RefUnwindSafe,
impl<T> Send for NONE<T>where
T: Send,
impl<T> Sync for NONE<T>where
T: Sync,
impl<T> Unpin for NONE<T>where
T: Unpin,
impl<T> UnwindSafe for NONE<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more