use wasm_bindgen::prelude::*; use wasm_bindgen_test::*; #[wasm_bindgen(module = "tests/wasm/optional_primitives.js")] extern "C" { fn optional_i32_js_identity(a: Option) -> Option; fn optional_u32_js_identity(a: Option) -> Option; fn optional_isize_js_identity(a: Option) -> Option; fn optional_usize_js_identity(a: Option) -> Option; fn optional_f32_js_identity(a: Option) -> Option; fn optional_f64_js_identity(a: Option) -> Option; fn optional_i8_js_identity(a: Option) -> Option; fn optional_u8_js_identity(a: Option) -> Option; fn optional_i16_js_identity(a: Option) -> Option; fn optional_u16_js_identity(a: Option) -> Option; fn optional_i64_js_identity(a: Option) -> Option; fn optional_u64_js_identity(a: Option) -> Option; fn optional_bool_js_identity(a: Option) -> Option; fn optional_char_js_identity(a: Option) -> Option; fn js_works(); } #[wasm_bindgen] pub fn optional_i32_none() -> Option { None } #[wasm_bindgen] pub fn optional_i32_zero() -> Option { Some(0) } #[wasm_bindgen] pub fn optional_i32_one() -> Option { Some(1) } #[wasm_bindgen] pub fn optional_i32_neg_one() -> Option { Some(-1) } #[wasm_bindgen] pub fn optional_i32_min() -> Option { Some(i32::min_value()) } #[wasm_bindgen] pub fn optional_i32_max() -> Option { Some(i32::max_value()) } #[wasm_bindgen] pub fn optional_i32_identity(a: Option) -> Option { optional_i32_js_identity(a) } #[wasm_bindgen] pub fn optional_u32_none() -> Option { None } #[wasm_bindgen] pub fn optional_u32_zero() -> Option { Some(0) } #[wasm_bindgen] pub fn optional_u32_one() -> Option { Some(1) } #[wasm_bindgen] pub fn optional_u32_min() -> Option { Some(u32::min_value()) } #[wasm_bindgen] pub fn optional_u32_max() -> Option { Some(u32::max_value()) } #[wasm_bindgen] pub fn optional_u32_identity(a: Option) -> Option { optional_u32_js_identity(a) } #[wasm_bindgen] pub fn optional_isize_none() -> Option { None } #[wasm_bindgen] pub fn optional_isize_zero() -> Option { Some(0) } #[wasm_bindgen] pub fn optional_isize_one() -> Option { Some(1) } #[wasm_bindgen] pub fn optional_isize_neg_one() -> Option { Some(-1) } #[wasm_bindgen] pub fn optional_isize_min() -> Option { Some(isize::min_value()) } #[wasm_bindgen] pub fn optional_isize_max() -> Option { Some(isize::max_value()) } #[wasm_bindgen] pub fn optional_isize_identity(a: Option) -> Option { optional_isize_js_identity(a) } #[wasm_bindgen] pub fn optional_usize_none() -> Option { None } #[wasm_bindgen] pub fn optional_usize_zero() -> Option { Some(0) } #[wasm_bindgen] pub fn optional_usize_one() -> Option { Some(1) } #[wasm_bindgen] pub fn optional_usize_min() -> Option { Some(usize::min_value()) } #[wasm_bindgen] pub fn optional_usize_max() -> Option { Some(usize::max_value()) } #[wasm_bindgen] pub fn optional_usize_identity(a: Option) -> Option { optional_usize_js_identity(a) } #[wasm_bindgen] pub fn optional_f32_none() -> Option { None } #[wasm_bindgen] pub fn optional_f32_zero() -> Option { Some(0f32) } #[wasm_bindgen] pub fn optional_f32_one() -> Option { Some(1f32) } #[wasm_bindgen] pub fn optional_f32_neg_one() -> Option { Some(-1f32) } #[wasm_bindgen] pub fn optional_f32_identity(a: Option) -> Option { optional_f32_js_identity(a) } #[wasm_bindgen] pub fn optional_f64_none() -> Option { None } #[wasm_bindgen] pub fn optional_f64_zero() -> Option { Some(0f64) } #[wasm_bindgen] pub fn optional_f64_one() -> Option { Some(1f64) } #[wasm_bindgen] pub fn optional_f64_neg_one() -> Option { Some(-1f64) } #[wasm_bindgen] pub fn optional_f64_identity(a: Option) -> Option { optional_f64_js_identity(a) } #[wasm_bindgen] pub fn optional_i8_none() -> Option { None } #[wasm_bindgen] pub fn optional_i8_zero() -> Option { Some(0) } #[wasm_bindgen] pub fn optional_i8_one() -> Option { Some(1) } #[wasm_bindgen] pub fn optional_i8_neg_one() -> Option { Some(-1) } #[wasm_bindgen] pub fn optional_i8_min() -> Option { Some(i8::min_value()) } #[wasm_bindgen] pub fn optional_i8_max() -> Option { Some(i8::max_value()) } #[wasm_bindgen] pub fn optional_i8_identity(a: Option) -> Option { optional_i8_js_identity(a) } #[wasm_bindgen] pub fn optional_u8_none() -> Option { None } #[wasm_bindgen] pub fn optional_u8_zero() -> Option { Some(0) } #[wasm_bindgen] pub fn optional_u8_one() -> Option { Some(1) } #[wasm_bindgen] pub fn optional_u8_min() -> Option { Some(u8::min_value()) } #[wasm_bindgen] pub fn optional_u8_max() -> Option { Some(u8::max_value()) } #[wasm_bindgen] pub fn optional_u8_identity(a: Option) -> Option { optional_u8_js_identity(a) } #[wasm_bindgen] pub fn optional_i16_none() -> Option { None } #[wasm_bindgen] pub fn optional_i16_zero() -> Option { Some(0) } #[wasm_bindgen] pub fn optional_i16_one() -> Option { Some(1) } #[wasm_bindgen] pub fn optional_i16_neg_one() -> Option { Some(-1) } #[wasm_bindgen] pub fn optional_i16_min() -> Option { Some(i16::min_value()) } #[wasm_bindgen] pub fn optional_i16_max() -> Option { Some(i16::max_value()) } #[wasm_bindgen] pub fn optional_i16_identity(a: Option) -> Option { optional_i16_js_identity(a) } #[wasm_bindgen] pub fn optional_u16_none() -> Option { None } #[wasm_bindgen] pub fn optional_u16_zero() -> Option { Some(0) } #[wasm_bindgen] pub fn optional_u16_one() -> Option { Some(1) } #[wasm_bindgen] pub fn optional_u16_min() -> Option { Some(u16::min_value()) } #[wasm_bindgen] pub fn optional_u16_max() -> Option { Some(u16::max_value()) } #[wasm_bindgen] pub fn optional_u16_identity(a: Option) -> Option { optional_u16_js_identity(a) } #[wasm_bindgen] pub fn optional_i64_none() -> Option { None } #[wasm_bindgen] pub fn optional_i64_zero() -> Option { Some(0) } #[wasm_bindgen] pub fn optional_i64_one() -> Option { Some(1) } #[wasm_bindgen] pub fn optional_i64_neg_one() -> Option { Some(-1) } #[wasm_bindgen] pub fn optional_i64_min() -> Option { Some(i64::min_value()) } #[wasm_bindgen] pub fn optional_i64_max() -> Option { Some(i64::max_value()) } #[wasm_bindgen] pub fn optional_i64_identity(a: Option) -> Option { optional_i64_js_identity(a) } #[wasm_bindgen] pub fn optional_u64_none() -> Option { None } #[wasm_bindgen] pub fn optional_u64_zero() -> Option { Some(0) } #[wasm_bindgen] pub fn optional_u64_one() -> Option { Some(1) } #[wasm_bindgen] pub fn optional_u64_min() -> Option { Some(u64::min_value()) } #[wasm_bindgen] pub fn optional_u64_max() -> Option { Some(u64::max_value()) } #[wasm_bindgen] pub fn optional_u64_identity(a: Option) -> Option { optional_u64_js_identity(a) } #[wasm_bindgen] pub fn optional_bool_none() -> Option { None } #[wasm_bindgen] pub fn optional_bool_false() -> Option { Some(false) } #[wasm_bindgen] pub fn optional_bool_true() -> Option { Some(true) } #[wasm_bindgen] pub fn optional_bool_identity(a: Option) -> Option { optional_bool_js_identity(a) } #[wasm_bindgen] pub fn optional_char_none() -> Option { None } #[wasm_bindgen] pub fn optional_char_letter() -> Option { Some('a') } #[wasm_bindgen] pub fn optional_char_face() -> Option { Some('😀') } #[wasm_bindgen] pub fn optional_char_identity(a: Option) -> Option { optional_char_js_identity(a) } #[wasm_bindgen_test] fn works() { js_works(); }