pub trait JsArgs {
// Required method
fn get_or_undefined(&self, index: usize) -> &JsValue;
}Expand description
A utility trait to make working with function arguments easier.
Required Methods§
Sourcefn get_or_undefined(&self, index: usize) -> &JsValue
fn get_or_undefined(&self, index: usize) -> &JsValue
Utility function to get a parameter from a [JsValue] or default to
JsValue::undefined() if get returns None.
Call this if you are thinking of calling something similar to
args.get(n).cloned().unwrap_or_default() or
args.get(n).unwrap_or(&undefined).
This returns a reference for efficiency, in case you only need to call methods of JsValue.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".