Skip to content

Commit 45cd941

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

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

crates/test/src/rt/scoped_tls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl<T> ScopedKey<T> {
3737
#[doc(hidden)]
3838
/// # Safety
3939
/// `inner` must only be accessed through `ScopedKey`'s API
40-
pub const unsafe fn new(inner: &'static Wrapper<Cell<*const ()>>) -> Self {
40+
pub(super) const unsafe fn new(inner: &'static Wrapper<Cell<*const ()>>) -> Self {
4141
Self {
4242
inner,
4343
_marker: PhantomData,

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)