mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-26 13:01:27 +03:00
add MaybeUninit to minicore
This commit is contained in:
@@ -27,6 +27,7 @@
|
|||||||
decl_macro,
|
decl_macro,
|
||||||
f16,
|
f16,
|
||||||
f128,
|
f128,
|
||||||
|
transparent_unions,
|
||||||
asm_experimental_arch,
|
asm_experimental_arch,
|
||||||
unboxed_closures
|
unboxed_closures
|
||||||
)]
|
)]
|
||||||
@@ -127,6 +128,25 @@ pub struct ManuallyDrop<T: PointeeSized> {
|
|||||||
}
|
}
|
||||||
impl<T: Copy + PointeeSized> Copy for ManuallyDrop<T> {}
|
impl<T: Copy + PointeeSized> Copy for ManuallyDrop<T> {}
|
||||||
|
|
||||||
|
#[lang = "maybe_uninit"]
|
||||||
|
#[repr(transparent)]
|
||||||
|
pub union MaybeUninit<T> {
|
||||||
|
uninit: (),
|
||||||
|
value: ManuallyDrop<T>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: Copy + PointeeSized> Copy for MaybeUninit<T> {}
|
||||||
|
|
||||||
|
impl<T> MaybeUninit<T> {
|
||||||
|
pub const fn uninit() -> Self {
|
||||||
|
Self { uninit: () }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const fn new(value: T) -> Self {
|
||||||
|
Self { value: ManuallyDrop { value } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[rustc_nonnull_optimization_guaranteed]
|
#[rustc_nonnull_optimization_guaranteed]
|
||||||
pub struct NonNull<T: ?Sized> {
|
pub struct NonNull<T: ?Sized> {
|
||||||
|
|||||||
Reference in New Issue
Block a user