pub trait DynCast{
// Required methods
fn instanceof(val: &Val) -> bool;
fn unchecked_from_val(v: Val) -> Self;
fn unchecked_from_val_ref(v: &Val) -> &Self;
// Provided methods
fn has_type<T>(&self) -> bool
where T: DynCast { ... }
fn dyn_into<T>(self) -> Result<T, Self>
where T: DynCast { ... }
fn dyn_ref<T>(&self) -> Option<&T>
where T: DynCast { ... }
fn unchecked_into<T>(self) -> T
where T: DynCast { ... }
fn unchecked_ref<T>(&self) -> &T
where T: DynCast { ... }
fn is_instance_of<T>(&self) -> bool
where T: DynCast { ... }
fn is_type_of(val: &Val) -> bool { ... }
}Expand description
Trait analogous to wasm-bindgen::JsCast.
Automatically available on every wrapper that is:
- holds a single
emlite::Val - implements
AsRef<Val>andInto<Val>
Required Methods§
Sourcefn instanceof(val: &Val) -> bool
fn instanceof(val: &Val) -> bool
Implementation of val instanceof ThisType.
Sourcefn unchecked_from_val(v: Val) -> Self
fn unchecked_from_val(v: Val) -> Self
Zero-cost unchecked conversion from Val into Self.
Sourcefn unchecked_from_val_ref(v: &Val) -> &Self
fn unchecked_from_val_ref(v: &Val) -> &Self
Zero-cost unchecked conversion from &Val into &Self.
Provided Methods§
fn has_type<T>(&self) -> boolwhere
T: DynCast,
fn dyn_into<T>(self) -> Result<T, Self>where
T: DynCast,
fn dyn_ref<T>(&self) -> Option<&T>where
T: DynCast,
fn unchecked_into<T>(self) -> Twhere
T: DynCast,
fn unchecked_ref<T>(&self) -> &Twhere
T: DynCast,
fn is_instance_of<T>(&self) -> boolwhere
T: DynCast,
Sourcefn is_type_of(val: &Val) -> bool
fn is_type_of(val: &Val) -> bool
Customisable brand check – defaults to instanceof.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.