Skip to content

Support for Maps #118

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
markandrus opened this issue Apr 10, 2018 · 6 comments
Closed

Support for Maps #118

markandrus opened this issue Apr 10, 2018 · 6 comments
Labels
more-types Adding support for more Rust types to cross the boundary

Comments

@markandrus
Copy link
Contributor

Is it planned to support Maps or other JavaScript data types in wasm-bindgen? For example,
I would like to be able to bind a function that returns a BTreeMap<String, String> (unless there is a more appropriate type for maps—I'm relatively new to Rust).

@alexcrichton
Copy link
Contributor

A good question! I think this is probably best done for now through something like #96 and the API would use JsValue, but would that still be too cumbersome?

@alexcrichton alexcrichton added the more-types Adding support for more Rust types to cross the boundary label Apr 16, 2018
@alexcrichton
Copy link
Contributor

Ok I'm gonna close this in favor of #96 as I think that's probably the route we'd take for this, but thanks for the report!

@couchand
Copy link

couchand commented May 4, 2018

I think it would be worth supporting the limited case of string to string maps. A handful of web APIs use them, for instance Headers and URLSearchParams.

@alexcrichton
Copy link
Contributor

@couchand in both those cases though those are dedicated classes, right? I'd imagine we'd want native bindings to them and then perhaps a helper method to convert them to a map on the Rust side?

@couchand
Copy link

couchand commented May 7, 2018

Unfortunately, I don't think dedicated classes would work there, since they have arbitrary keys.

@alexcrichton
Copy link
Contributor

Ah if that's the case then yeah we may need to add some more support for more maps in the future as well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more-types Adding support for more Rust types to cross the boundary
Projects
None yet
Development

No branches or pull requests

3 participants