7 releases (breaking)
0.7.0 | Nov 28, 2024 |
---|---|
0.6.0 | Jan 3, 2024 |
0.5.0 | Jul 29, 2023 |
0.4.0 | May 7, 2023 |
0.1.0 | Apr 7, 2023 |
#882 in Rust patterns
193 downloads per month
21KB
331 lines
maybe-uninit-ext
Extended maybe-uninit types.
lib.rs
:
Extended maybe-uninit types.
Example
// Creates a 4x4 grid of `MaybeUninit` values.
let mut grid = maybe_uninit_ext::uninit::<[[MaybeUninit<usize>; 4]; 4]>();
grid.iter_mut().enumerate().for_each(|(i, row)| {
row.iter_mut().enumerate().for_each(|(j, tile)| {
tile.write(i * j);
});
});
// SAFETY: The grid was fully initialized.
let grid = unsafe { maybe_uninit_ext::assume_init(grid) };
assert_eq!(
grid,
[[0, 0, 0, 0], [0, 1, 2, 3], [0, 2, 4, 6], [0, 3, 6, 9]],
);
Minimum supported Rust version
The MSRV is currently 1.83.
This may change between minor versions.
License
I release this crate into the public domain under the Unlicense.