fix missing sync bounds

This commit is contained in:
Melvin Wang 2025-06-18 15:38:57 -07:00
parent 905aed45f9
commit 051c63fea2
2 changed files with 7 additions and 2 deletions

View File

@ -31,7 +31,12 @@ union Data<T, F> {
f: ManuallyDrop<F>,
}
unsafe impl<T, F> Sync for LazyLock<T, F> {}
unsafe impl<T, F> Sync for LazyLock<T, F>
where
T: Sync,
F: Sync,
{
}
impl<T, F: FnOnce() -> T> LazyLock<T, F> {
/// Create a new uninitialized `StaticLock`.

View File

@ -42,7 +42,7 @@ pub struct OnceLock<T> {
data: Cell<MaybeUninit<T>>,
}
unsafe impl<T> Sync for OnceLock<T> {}
unsafe impl<T> Sync for OnceLock<T> where T: Sync {}
impl<T> OnceLock<T> {
/// Create a new uninitialized `OnceLock`.