pub struct LazyCell<T: 'static> { /* private fields */ }Expand description
A runtime-local accessor for lazily initialized JavaScript values.
This type provides safe access to cached JavaScript global values, ensuring the value is initialized on first access in the active runtime.
§Example
ⓘ
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(thread_local_v2, js_name = window)]
pub static WINDOW: Window;
}
WINDOW.with(|window| {
let doc = window.document();
});Implementations§
Auto Trait Implementations§
impl<T> Freeze for LazyCell<T>
impl<T> RefUnwindSafe for LazyCell<T>
impl<T> Send for LazyCell<T>
impl<T> Sync for LazyCell<T>
impl<T> Unpin for LazyCell<T>
impl<T> UnsafeUnpin for LazyCell<T>
impl<T> UnwindSafe for LazyCell<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more