rebase to handle JsString

This commit is contained in:
Sendil Kumar 2018-06-24 20:48:37 +02:00
parent 233b35254f
commit 32bc9f271c
2 changed files with 6 additions and 6 deletions

View File

@ -249,14 +249,14 @@ extern {
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed
#[wasm_bindgen(catch, method, js_name = toFixed)]
pub fn to_fixed(this: &Number, digits: u8) -> Result<String, JsValue>;
pub fn to_fixed(this: &Number, digits: u8) -> Result<JsString, JsValue>;
/// The toExponential() method returns a string representing the Number
/// object in exponential notation.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential
#[wasm_bindgen(catch, method, js_name = toExponential)]
pub fn to_exponential(this: &Number, fraction_digits: u8) -> Result<String, JsValue>;
pub fn to_exponential(this: &Number, fraction_digits: u8) -> Result<JsString, JsValue>;
/// The toString() method returns a string representing the
/// specified Number object.

View File

@ -138,11 +138,11 @@ fn to_fixed() {
use wasm_bindgen::js;
#[wasm_bindgen]
pub fn to_fixed(this: &js::Number, digits: u8) -> String {
pub fn to_fixed(this: &js::Number, digits: u8) -> js::JsString {
let result = this.to_fixed(digits);
let result = match result {
Ok(num) => num,
Err(_err) => "RangeError".to_string()
Err(_err) => "RangeError".into()
};
result
}
@ -170,11 +170,11 @@ fn to_exponential() {
use wasm_bindgen::js;
#[wasm_bindgen]
pub fn to_exponential(this: &js::Number, fraction_digits: u8) -> String {
pub fn to_exponential(this: &js::Number, fraction_digits: u8) -> js::JsString {
let result = this.to_exponential(fraction_digits);
let result = match result {
Ok(num) => num,
Err(_err) => "RangeError".to_string()
Err(_err) => "RangeError".into()
};
result
}