@@ -205,7 +205,7 @@ impl Inner {
205
205
// writes to the cell's value are visible to the cell's readers.
206
206
let prev_state = self . state . fetch_or ( READY_BIT , Ordering :: Release ) ;
207
207
208
- debug_assert_eq ! ( prev_state & READY_BIT , 0 , "Invalid state: somoene else set READY_BIT" ) ;
208
+ debug_assert_eq ! ( prev_state & READY_BIT , 0 , "Invalid state: someone else set READY_BIT" ) ;
209
209
}
210
210
}
211
211
@@ -280,7 +280,7 @@ impl<'a> Drop for QuickInitGuard<'a> {
280
280
let guard = waiter. guard . expect ( "No guard available even without polling" ) ;
281
281
if guard. queue . is_null ( ) {
282
282
// The queue was already freed by someone else before we got our QueueRef (this must
283
- // have happend between the load of prev_state and initialize, because otherwise we
283
+ // have happened between the load of prev_state and initialize, because otherwise we
284
284
// would have taken the fast path). This implies that all other tasks have noticed
285
285
// READY_BIT and do not need waking, so there is nothing left for us to do except
286
286
// release our reference.
@@ -413,7 +413,7 @@ impl<T> OnceCell<T> {
413
413
/// Gets the contents of the cell, initializing it with `init` if the cell was empty.
414
414
///
415
415
/// Many tasks may call `get_or_init` concurrently with different initializing futures, but
416
- /// it is guaranteed that only one future will be executed as long as the resuting future is
416
+ /// it is guaranteed that only one future will be executed as long as the resulting future is
417
417
/// polled to completion.
418
418
///
419
419
/// If `init` panics, the panic is propagated to the caller, and the cell remains uninitialized.
@@ -642,6 +642,20 @@ where
642
642
}
643
643
}
644
644
645
+ impl < T , F > Lazy < T , F >
646
+ where
647
+ F : Future < Output = T > + Unpin ,
648
+ {
649
+ /// Forces the evaluation of this lazy value and returns a reference to the result.
650
+ ///
651
+ /// Unlike [Self::get], this does not require pinning the object.
652
+ pub async fn get_unpin ( & self ) -> & T {
653
+ // The get() function itself does not use the fact that T is pinned, and Pin::deref already
654
+ // exposes a &T from Pin<&T> (although not with the right lifetime).
655
+ unsafe { Pin :: into_inner_unchecked ( Pin :: new_unchecked ( self ) . get ( ) . await ) }
656
+ }
657
+ }
658
+
645
659
impl < T , F > Lazy < T , F > {
646
660
/// Creates a new lazy value with the given initializing future.
647
661
///
0 commit comments