Fix missing unsafe block for target arch wasm32
This commit is contained in:
@@ -377,10 +377,17 @@ pub mod statik {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn get(&self, init: fn() -> T) -> Option<&'static T> {
|
pub unsafe fn get(&self, init: fn() -> T) -> Option<&'static T> {
|
||||||
let value = match self.inner.get() {
|
// SAFETY: The caller must ensure no reference is ever handed out to
|
||||||
Some(ref value) => value,
|
// the inner cell nor mutable reference to the Option<T> inside said
|
||||||
None => self.inner.initialize(init),
|
// cell. This make it safe to hand a reference, though the lifetime
|
||||||
|
// of 'static is itself unsafe, making the get method unsafe.
|
||||||
|
let value = unsafe {
|
||||||
|
match self.inner.get() {
|
||||||
|
Some(ref value) => value,
|
||||||
|
None => self.inner.initialize(init),
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Some(value)
|
Some(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user