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

Add a TryIntoJs trait and derive macro to transform Rust values into JsValue #3874

Closed
hansl opened this issue Jun 13, 2024 · 0 comments · Fixed by #3999
Closed

Add a TryIntoJs trait and derive macro to transform Rust values into JsValue #3874

hansl opened this issue Jun 13, 2024 · 0 comments · Fixed by #3999
Labels
API enhancement New feature or request
Milestone

Comments

@hansl
Copy link
Contributor

hansl commented Jun 13, 2024

Basically the opposite of TryFromJs.

Conversions From<T> for JsValue are implemented for a lot of primitive values, but not as much for complex Rust types.

This is useful when calling into JavaScript functions (using JsObject::call()) and passing in Rust values that are not primitive.

@hansl hansl added the enhancement New feature or request label Jun 13, 2024
@jedel1043 jedel1043 added the API label Jun 13, 2024
@jedel1043 jedel1043 added this to the v0.18.1 milestone Jun 13, 2024
@raskad raskad modified the milestones: v0.18.1, v0.19.0 Jul 8, 2024
@jedel1043 jedel1043 modified the milestones: v0.19.0, next-release Jul 18, 2024
Nikita-str added a commit to Nikita-str/boa that referenced this issue Sep 19, 2024
Nikita-str added a commit to Nikita-str/boa that referenced this issue Sep 19, 2024
is it ok to use `create_data_property_or_throw`?
in other words, am I create an object correctly?
Nikita-str added a commit to Nikita-str/boa that referenced this issue Sep 19, 2024
Nikita-str added a commit to Nikita-str/boa that referenced this issue Sep 19, 2024
Nikita-str added a commit to Nikita-str/boa that referenced this issue Sep 19, 2024
github-merge-queue bot pushed a commit that referenced this issue Oct 26, 2024
* #3874: `TryIntoJs` impl for primitive types

* #3874: `#[derive(TryIntoJs)]`

is it ok to use `create_data_property_or_throw`?
in other words, am I create an object correctly?

* #3874: some (but not enough) tests

* #3874: fix `TryintoJs` derive bug in multi attr case

* #3874: `TryIntoJs` derive macro example

* fix paths in derive macro

* make lint happy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API enhancement New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants