pub enum Cast<'a, T>{
Ref {
anchor: <T as RefFromWasmAbi>::Anchor,
},
OwnedRef {
js_value: Option<JsValue>,
anchor: Option<<T as RefFromWasmAbi>::Anchor>,
},
LongRef {
anchor: <T as LongRefFromWasmAbi>::Anchor,
},
Value {
value: Option<T>,
},
_Unreachable(Infallible, &'a PhantomData<T>),
}
Expand description
A wrapper for a Rust object that can be either a reference or a value.
This wrapper is used to carry a Rust (WASM ABI) reference provided by
wasm_bindgen
, but at the same time allows creation of a temporary
object that can be created by interpreting the source user-supplied data.
Cast
then provides Cast::as_ref()
to obtain the internally held
reference and Cast::into_owned()
where the latter will consume the
value or clone the reference.
Variants§
Ref
Fields
§
anchor: <T as RefFromWasmAbi>::Anchor
OwnedRef
LongRef
Fields
§
anchor: <T as LongRefFromWasmAbi>::Anchor
Value
_Unreachable(Infallible, &'a PhantomData<T>)
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<'a, T> Freeze for Cast<'a, T>
impl<'a, T> RefUnwindSafe for Cast<'a, T>where
<T as RefFromWasmAbi>::Anchor: RefUnwindSafe,
<T as LongRefFromWasmAbi>::Anchor: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, T> !Send for Cast<'a, T>
impl<'a, T> !Sync for Cast<'a, T>
impl<'a, T> Unpin for Cast<'a, T>
impl<'a, T> UnwindSafe for Cast<'a, T>where
<T as RefFromWasmAbi>::Anchor: UnwindSafe,
<T as LongRefFromWasmAbi>::Anchor: UnwindSafe,
T: UnwindSafe + RefUnwindSafe,
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