Skip to content

Implement Default for JS types #2626

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

Merged
merged 4 commits into from
Jul 20, 2021

Conversation

Jules-Bertholet
Copy link
Contributor

@Jules-Bertholet Jules-Bertholet commented Jul 17, 2021

  • Implement the Default trait for types in js-sys where it makes sense
  • Generate a Default impl for WebIDL types with zero-argument constructors

@alexcrichton
Copy link
Contributor

Thanks for this!

I think the 0-argument ctor makes sense for web-sys, although some of the default implementations in js-sys seem like they're a bit ambitiuos, e.g. creating an error without a string and such. Could the initial set of ctors in js-sys be a bit more conservative to basically match Default semantics in Rust? (e.g. errors typically don't implement Default)

@Jules-Bertholet
Copy link
Contributor Author

Ready for review

@alexcrichton alexcrichton merged commit b97837b into rustwasm:master Jul 20, 2021
@Jules-Bertholet Jules-Bertholet deleted the add-default-impls branch July 20, 2021 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants