Skip to content

Commit f120807

Browse files
committed
style: allow unsafe code around UnsafeCell::into_inner() call
Rust 1.25 changed UnsafeCell::into_inner() from unsafe to safe function. This unsafe can be removed when supporting Rust older than 1.25 is not needed.
1 parent 51312dd commit f120807

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/lib.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,11 @@ impl<T> LazyCell<T> {
135135

136136
/// Consumes this `LazyCell`, returning the underlying value.
137137
pub fn into_inner(self) -> Option<T> {
138-
self.inner.into_inner()
138+
// Rust 1.25 changed UnsafeCell::into_inner() from unsafe to safe
139+
// function. This unsafe can be removed when supporting Rust older than
140+
// 1.25 is not needed.
141+
#[allow(unused_unsafe)]
142+
unsafe { self.inner.into_inner() }
139143
}
140144
}
141145

@@ -206,7 +210,11 @@ impl<T> AtomicLazyCell<T> {
206210

207211
/// Consumes this `LazyCell`, returning the underlying value.
208212
pub fn into_inner(self) -> Option<T> {
209-
self.inner.into_inner()
213+
// Rust 1.25 changed UnsafeCell::into_inner() from unsafe to safe
214+
// function. This unsafe can be removed when supporting Rust older than
215+
// 1.25 is not needed.
216+
#[allow(unused_unsafe)]
217+
unsafe { self.inner.into_inner() }
210218
}
211219
}
212220

0 commit comments

Comments
 (0)