Skip to content

Soft-deprecate Number::new and Boolean::new #1446

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

Closed
RReverser opened this issue Apr 11, 2019 · 2 comments · Fixed by #1447
Closed

Soft-deprecate Number::new and Boolean::new #1446

RReverser opened this issue Apr 11, 2019 · 2 comments · Fixed by #1447

Comments

@RReverser
Copy link
Member

RReverser commented Apr 11, 2019

Motivation

Boxed primitives are extremely rare and unidiomatic in real-world JavaScript, and cause more problems to support than worth it.

Proposed Solution

As discussed in #1405, we would want to deprecate fn new on Number and Boolean to discourage use of boxed primitives, probably in favour of adding From<f64> and From<bool> implementations correspondingly (which will create real primitives).

Alternatives

Keep the methods, but not support them actively in other parts of the stack. This might be confusing though.

Additional Context

For what it's worth, we don't provide fn new on e.g. JsString so this aligns primitives nicely to a common format.

@RReverser
Copy link
Member Author

cc @Pauan @alexcrichton

@alexcrichton
Copy link
Contributor

This seems reasonable to me!

alexcrichton added a commit to alexcrichton/wasm-bindgen that referenced this issue Apr 11, 2019
* Ensure `PartialEq` is implemented from these types to native Rust types
* Implement `From` between these type and native Rust types
* Deprecated `Number::new` and `Boolean::new` to discourage use of the
  object forms, recommending the `from` constructors instead.

Closes rustwasm#1446
alexcrichton added a commit to alexcrichton/wasm-bindgen that referenced this issue Apr 11, 2019
* Ensure `PartialEq` is implemented from these types to native Rust types
* Implement `From` between these type and native Rust types
* Deprecated `Number::new` and `Boolean::new` to discourage use of the
  object forms, recommending the `from` constructors instead.

Closes rustwasm#1446
alexcrichton added a commit to alexcrichton/wasm-bindgen that referenced this issue Apr 12, 2019
* Ensure `PartialEq` is implemented from these types to native Rust types
* Implement `From` between these type and native Rust types
* Deprecated `Number::new` and `Boolean::new` to discourage use of the
  object forms, recommending the `from` constructors instead.

Closes rustwasm#1446
alexcrichton added a commit to alexcrichton/wasm-bindgen that referenced this issue Apr 12, 2019
* Ensure `PartialEq` is implemented from these types to native Rust types
* Implement `From` between these type and native Rust types
* Deprecated `Number::new` and `Boolean::new` to discourage use of the
  object forms, recommending the `from` constructors instead.

Closes rustwasm#1446
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.

2 participants