-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from yoshuawuyts/no-maybedone-join
Remove `MaybeDone` from `impl Join for array`
- Loading branch information
Showing
4 changed files
with
133 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use std::mem::{self, MaybeUninit}; | ||
|
||
/// Extracts the values from an array of `MaybeUninit` containers. | ||
/// | ||
/// # Safety | ||
/// | ||
/// It is up to the caller to guarantee that all elements of the array are | ||
/// in an initialized state. | ||
/// | ||
/// Inlined version of: https://doc.rust-lang.org/std/mem/union.MaybeUninit.html#method.array_assume_init | ||
pub(crate) unsafe fn array_assume_init<T, const N: usize>(array: [MaybeUninit<T>; N]) -> [T; N] { | ||
// SAFETY: | ||
// * The caller guarantees that all elements of the array are initialized | ||
// * `MaybeUninit<T>` and T are guaranteed to have the same layout | ||
// * `MaybeUninit` does not drop, so there are no double-frees | ||
// And thus the conversion is safe | ||
let ret = unsafe { (&array as *const _ as *const [T; N]).read() }; | ||
|
||
// FIXME: required to avoid `~const Destruct` bound | ||
mem::forget(array); | ||
ret | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.