pub struct Parent<T> { /* private fields */ }Expand description
Storage wrapper for the auto-injected parent field on a struct that
declares #[wasm_bindgen(extends = Parent)].
Under the hood this is an Rc<WasmRefCell<T>> so that wasm-bindgen can
produce a separately-refcounted parent pointer for JS-side prototype
dispatch. Use Parent::borrow / Parent::borrow_mut to access the
inner value. You should not need to construct Parent<T> directly
outside the child’s constructor; the From<T> impl is the typical way
to initialize the injected parent field.
Clone is a cheap Rc clone — both copies point at the same parent
data. Debug prints the wrapper plus the inner T (when T: Debug).
Implementations§
Source§impl<T> Parent<T>
impl<T> Parent<T>
Sourcepub fn borrow(&self) -> Ref<'_, T>
pub fn borrow(&self) -> Ref<'_, T>
Immutably borrows the wrapped value.
Panics (or throws on the wasm target) if the value is currently mutably borrowed.
Sourcepub fn borrow_mut(&self) -> RefMut<'_, T>
pub fn borrow_mut(&self) -> RefMut<'_, T>
Mutably borrows the wrapped value.
Panics (or throws on the wasm target) if the value is currently borrowed.