Default Array-of-Option<T> Macros
Macros to make your life easier when dealing with default-initialized
arrays of Option<T> or Cell<Option<T>> for non-Copy types of T to [None, ..].
You may need it if ...
- You need an array of
[Option<T>; N]initialized to[None; N], or - You need an array of
[Cell<Option<T>>; N]initialized to[Cell::new(None); N], or - You need an array of
[RefCell<Option<T>>; N]initialized to[RefCell::new(None); N].
You will not need it if ...
- Your types already implement
CopyorCloneand you don't need cells. - You require
#![forbid(unsafe_code)].
Examples
use Cell;
use ArraySetCell;
// This type does not implement Copy.
;
Likewise, arrays of Cell<Option<T>> can be created.
I cannot have unsafe code
If you cannot have unsafe code in your project, something like the following can be used: