+impl<T> StackInit<T> {
+ /// Creates a new [`StackInit<T>`] that is uninitialized. Use [`stack_pin_init`] instead of this
+ /// primitive.
+ ///
+ /// [`stack_pin_init`]: kernel::stack_pin_init
+ #[inline]
+ pub fn uninit() -> Self {
+ Self(MaybeUninit::uninit(), false)
+ }
+
+ /// Initializes the contents and returns the result.
+ ///
+ /// # Safety
+ ///
+ /// The caller ensures that `self` is on the stack and not accessible in any other way, if this
+ /// function returns `Ok`.
+ #[inline]
+ pub unsafe fn init<E>(&mut self, init: impl PinInit<T, E>) -> Result<Pin<&mut T>, E> {
Could this be made safe if the signature takes `self: Pin<&mut Self>`
instead?
The std `pin!` macro is stable in
1.68 so we can just `core::pin::pin!(StackInit::uninit())` and then
call `init` on it.
Best,
Gary