We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 578e714 commit e56ea68Copy full SHA for e56ea68
library/std/src/lazy.rs
@@ -47,7 +47,25 @@ pub struct SyncOnceCell<T> {
47
once: Once,
48
// Whether or not the value is initialized is tracked by `state_and_queue`.
49
value: UnsafeCell<MaybeUninit<T>>,
50
- // Make sure dropck understands we're dropping T in our Drop impl.
+ /// `PhantomData` to make sure dropck understands we're dropping T in our Drop impl.
51
+ ///
52
+ /// ```compile_fail,E0597
53
+ /// #![feature(once_cell)]
54
55
+ /// use std::lazy::SyncOnceCell;
56
57
+ /// struct A<'a>(&'a str);
58
59
+ /// impl<'a> Drop for A<'a> {
60
+ /// fn drop(&mut self) {}
61
+ /// }
62
63
+ /// let cell = SyncOnceCell::new();
64
+ /// {
65
+ /// let s = String::new();
66
+ /// let _ = cell.set(A(&s));
67
68
+ /// ```
69
_marker: PhantomData<T>,
70
}
71
0 commit comments