Add same unsafe bound on get_or_init_slow
This commit is contained in:
@@ -57,12 +57,18 @@ where
|
|||||||
if let State::Alive = self.state.get() {
|
if let State::Alive = self.state.get() {
|
||||||
self.value.get().cast()
|
self.value.get().cast()
|
||||||
} else {
|
} else {
|
||||||
self.get_or_init_slow(i, f)
|
unsafe { self.get_or_init_slow(i, f) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// # Safety
|
||||||
|
/// The `self` reference must remain valid until the TLS destructor is run.
|
||||||
#[cold]
|
#[cold]
|
||||||
fn get_or_init_slow(&self, i: Option<&mut Option<T>>, f: impl FnOnce() -> T) -> *const T {
|
unsafe fn get_or_init_slow(
|
||||||
|
&self,
|
||||||
|
i: Option<&mut Option<T>>,
|
||||||
|
f: impl FnOnce() -> T,
|
||||||
|
) -> *const T {
|
||||||
match self.state.get() {
|
match self.state.get() {
|
||||||
State::Uninitialized => {}
|
State::Uninitialized => {}
|
||||||
State::Alive => return self.value.get().cast(),
|
State::Alive => return self.value.get().cast(),
|
||||||
|
|||||||
Reference in New Issue
Block a user