We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Is it possible to make a struct iterable?
I want to define a struct in rust:
#[wasm_bindgen] unsafe extern "C" { pub unsafe fn print(pos: Pos); } #[wasm_bindgen] struct Pos { x: f64, y: f64 } fn main() { print(Pos { x: 1.0, y: 2.0 }); }
so that if I pass it to js it can be iterated (implement Symbols.iterator method):
function print(pos) { for (const key in pos) { console.log(`${key}: ${pos[key]}`); } }
prints:
x: 1 y: 2
The text was updated successfully, but these errors were encountered:
This is not currently supported. See #1478 for workarounds. Also see #4142 for a proposal on how to address this.
Closing as duplicate of #1478.
Sorry, something went wrong.
No branches or pull requests
Summary
Is it possible to make a struct iterable?
Additional Details
I want to define a struct in rust:
so that if I pass it to js it can be iterated (implement Symbols.iterator method):
prints:
The text was updated successfully, but these errors were encountered: