Struct Parent

pub struct Parent<T> { /* private fields */ }

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

impl<T> Parent<T>

fn new(value: T) -> Self

Wraps a value in a new Parent<T>.

fn borrow(&self) -> Ref<'_, T>

Immutably borrows the wrapped value.

Panics (or throws on the wasm target) if the value is currently mutably borrowed.

fn borrow_mut(&self) -> RefMut<'_, T>

Mutably borrows the wrapped value.

Panics (or throws on the wasm target) if the value is currently borrowed.

Trait Implementations

impl<T> Clone for Parent<T>

fn clone(&self) -> Self

impl<T> From<T> for Parent<T>

fn from(value: T) -> Self

impl<T: Debug> Debug for Parent<T>

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Auto Trait Implementations

impl<T> !Send for Parent<T>

impl<T> !Sync for Parent<T>

impl<T> Freeze for Parent<T> where Rc<WasmRefCell<T>>: Freeze,

impl<T> RefUnwindSafe for Parent<T> where Rc<WasmRefCell<T>>: RefUnwindSafe,

impl<T> Unpin for Parent<T> where Rc<WasmRefCell<T>>: Unpin,

impl<T> UnsafeUnpin for Parent<T> where Rc<WasmRefCell<T>>: UnsafeUnpin,

impl<T> UnwindSafe for Parent<T> where Rc<WasmRefCell<T>>: UnwindSafe,

Blanket Implementations

impl<S, T> Upcast<T> for Parent<T> where T: UpcastFrom<S> + ?Sized, S: ?Sized,

impl<T> Any for Parent<T> where T: 'static + ?Sized,

impl<T> Borrow<T> for Parent<T> where T: ?Sized,

impl<T> BorrowMut<T> for Parent<T> where T: ?Sized,

impl<T> CloneToUninit for Parent<T> where T: Clone,

impl<T> From<T> for Parent<T>

impl<T> ToOwned for Parent<T> where T: Clone,

impl<T, U> Into<U> for Parent<T> where U: From<T>,

impl<T, U> TryFrom<U> for Parent<T> where U: Into<T>,

impl<T, U> TryInto<U> for Parent<T> where U: TryFrom<T>,