-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Remove try_array_to_vec
and downcast
#82
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm generally, though please could the doc be updated as previously noted.
I don't suppose that wasm-bindgen supports Vec<&identifiers::UserId>
, thus avoiding the drop problem?
Particularly given this is a not-very-obvious breaking change, could you add a note to the the CHANGELOG warning applications about this?
It's not supported, indeed. I've updated the docs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry to be so picky about this, but this is such alien behaviour in javascript that I think it's really important to accurately document the hell out of it.
Now that `wasm-bindgen` supports `Vec<T>` and `Option<Vec<T>>`, we no longer need `try_array_to_vec`. This patch removes this helper function.
The `downcast` function is removed in this patch because it was incompatible with JS code minifier. Instead, we now rely on the new `wasm_bindgen::convert::TryFromJsValue` API. This patch also replaces `&Array` by `Vec<T>`. It's fine, except that JS arrays that are sent to Rust are going to be dropped after the functions return. It's quite unsual for JS, but documentations have been updated accordingly.
This can be helpful when the `user_id` is dropped on the Rust side.
This patch moves the `OlmMachine::import_exported_room_keys_helper` to a `impl` that is not annotated by `#[wasm_bindgen]` because it doesn't have to live in the JS binding.
This patch replaces a few `js_sys::Array` by `std::vec::Vec` when possible. It makes the code simpler, and `wasm_bindgen` now handles `Vec` well for us.
I've rebased the patch. I've updated the documentation. I've also replaced a couple more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, looks great apart from a few more documentation nits!
This patch updates
wasm-bindgen
to 0.2.89. It allows to removetry_array_to_vec
(which was fine, but no more necessary), and to removedowncast
(which was a problem, see #51).This patch should ideally be reviewed commit by commit.