add MaybeUninit to minicore

This commit is contained in:
Folkert de Vries
2025-10-08 15:29:24 +02:00
parent ec2d669db8
commit aa38b7fcac
+20
View File
@@ -27,6 +27,7 @@
decl_macro,
f16,
f128,
transparent_unions,
asm_experimental_arch,
unboxed_closures
)]
@@ -127,6 +128,25 @@ pub struct ManuallyDrop<T: PointeeSized> {
}
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)]
#[rustc_nonnull_optimization_guaranteed]
pub struct NonNull<T: ?Sized> {