From 30fc99b724935442a938395e998db83368d6b822 Mon Sep 17 00:00:00 2001 From: Danielle Pham Date: Mon, 13 Aug 2018 17:03:58 -0400 Subject: [PATCH] Use u32 params for String.from_char_code bindings --- crates/js-sys/src/lib.rs | 10 +++++----- crates/js-sys/tests/wasm/JsString.rs | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/js-sys/src/lib.rs b/crates/js-sys/src/lib.rs index 60c92d872..799415797 100644 --- a/crates/js-sys/src/lib.rs +++ b/crates/js-sys/src/lib.rs @@ -2950,23 +2950,23 @@ extern "C" { /// There are a few bindings to `from_char_code` in `js-sys`: `from_char_code1`, `from_char_code2`, etc... /// with different arities. #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)] - pub fn from_char_code1(a: f64) -> JsString; + pub fn from_char_code1(a: u32) -> JsString; /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)] - pub fn from_char_code2(a: f64, b: f64) -> JsString; + pub fn from_char_code2(a: u32, b: u32) -> JsString; /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)] - pub fn from_char_code3(a: f64, b: f64, c: f64) -> JsString; + pub fn from_char_code3(a: u32, b: u32, c: u32) -> JsString; /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)] - pub fn from_char_code4(a: f64, b: f64, c: f64, d: f64) -> JsString; + pub fn from_char_code4(a: u32, b: u32, c: u32, d: u32) -> JsString; /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)] - pub fn from_char_code5(a: f64, b: f64, c: f64, d: f64, e: f64) -> JsString; + pub fn from_char_code5(a: u32, b: u32, c: u32, d: u32, e: u32) -> JsString; /// The `includes()` method determines whether one string may be found /// within another string, returning true or false as appropriate. diff --git a/crates/js-sys/tests/wasm/JsString.rs b/crates/js-sys/tests/wasm/JsString.rs index 0c536c346..4b276ba39 100644 --- a/crates/js-sys/tests/wasm/JsString.rs +++ b/crates/js-sys/tests/wasm/JsString.rs @@ -61,8 +61,8 @@ fn ends_with() { #[wasm_bindgen_test] fn from_char_code() { let s = "½+¾="; - let codes : Vec = s.chars() - .map(|char| char as u32 as f64) + let codes : Vec = s.chars() + .map(|char| char as u32) .collect(); assert_eq!(JsString::from_char_code1(codes[0]), "½");