Skip to content

Commit 0d0ee01

Browse files
committed
Fix no_std MSRV compatibility
1 parent 0c69409 commit 0d0ee01

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/lib.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,20 +1595,23 @@ pub mod __rt {
15951595
/// Wrapper around [`::once_cell::unsync::Lazy`] adding some compatibility methods with
15961596
/// [`std::thread::LocalKey`] and adding `Send + Sync` when `atomics` is not enabled.
15971597
#[cfg(not(feature = "std"))]
1598-
pub struct LazyCell<T>(::once_cell::unsync::Lazy<T>);
1598+
pub struct LazyCell<T, F = fn() -> T>(::once_cell::unsync::Lazy<T, F>);
15991599

16001600
#[cfg(all(not(target_feature = "atomics"), not(feature = "std")))]
1601-
unsafe impl<T> Sync for LazyCell<T> {}
1601+
unsafe impl<T, F> Sync for LazyCell<T, F> {}
16021602

16031603
#[cfg(all(not(target_feature = "atomics"), not(feature = "std")))]
1604-
unsafe impl<T> Send for LazyCell<T> {}
1604+
unsafe impl<T, F> Send for LazyCell<T, F> {}
16051605

16061606
#[cfg(not(feature = "std"))]
1607-
impl<T> LazyCell<T> {
1608-
pub const fn new(init: fn() -> T) -> LazyCell<T> {
1607+
impl<T, F> LazyCell<T, F> {
1608+
pub const fn new(init: F) -> LazyCell<T, F> {
16091609
Self(::once_cell::unsync::Lazy::new(init))
16101610
}
1611+
}
16111612

1613+
#[cfg(not(feature = "std"))]
1614+
impl<T, F: FnOnce() -> T> LazyCell<T, F> {
16121615
pub(crate) fn try_with<R>(
16131616
&self,
16141617
f: impl FnOnce(&T) -> R,

0 commit comments

Comments
 (0)