mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-23 01:31:34 +00:00
More fixes for iterating example
This commit is contained in:
@ -76,7 +76,7 @@ pub fn collect_numbers(some_iterable: &JsValue) -> Result<js_sys::Array, JsValue
|
|||||||
let nums = js_sys::Array::new();
|
let nums = js_sys::Array::new();
|
||||||
|
|
||||||
let iterator = js_sys::try_iter(some_iterable)?.ok_or_else(|| {
|
let iterator = js_sys::try_iter(some_iterable)?.ok_or_else(|| {
|
||||||
"need to pass iterable JS values!".into()
|
"need to pass iterable JS values!"
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
for x in iterator {
|
for x in iterator {
|
||||||
@ -85,7 +85,7 @@ pub fn collect_numbers(some_iterable: &JsValue) -> Result<js_sys::Array, JsValue
|
|||||||
let x = x?;
|
let x = x?;
|
||||||
|
|
||||||
// If `x` is a number, add it to our array of numbers!
|
// If `x` is a number, add it to our array of numbers!
|
||||||
if x.is_f64() {
|
if x.as_f64().is_some() {
|
||||||
nums.push(&x);
|
nums.push(&x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user