Skip to content
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

js-sys Array::set_length #3244

Closed
romamik opened this issue Jan 17, 2023 · 1 comment · Fixed by #3246
Closed

js-sys Array::set_length #3244

romamik opened this issue Jan 17, 2023 · 1 comment · Fixed by #3246

Comments

@romamik
Copy link

romamik commented Jan 17, 2023

Motivation

In javascript, it is possible to set the length of an array, why not allow it from the rust?

Proposed Solution

Just add this to Array externs in the js-sys crate.

#[wasm_bindgen(method, structural, setter)]
pub fn set_length(this: &Array, value: u32);

Alternatives

Now one can use Reflect::set for this, but this is ugly.

@romamik
Copy link
Author

romamik commented Jan 18, 2023

Liamolucko added a commit to Liamolucko/wasm-bindgen that referenced this issue Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant