Skip to main content

JsArgs

Trait JsArgs 

Source
pub trait JsArgs {
    // Required method
    fn get_or_undefined(&self, index: usize) -> &JsValue;
}

Required Methods§

Source

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, so try to minimize calling clone.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl JsArgs for [JsValue]

Source§

fn get_or_undefined(&self, index: usize) -> &JsValue

Implementors§