rusty_v8
rusty_v8 copied to clipboard
Support a `.iter()` method on `Array`
trafficstars
Convenience method. Could imagine it going somewhere like here https://github.com/denoland/rusty_v8/blob/3315ccd4e9d2c98a6c626ff8c047fa9817769da3/src/object.rs#L551
Look something like this (ish)
pub fn iter(&self, scope: &mut HandleScope<'s>) -> impl Iterator<Item = Value> { ... }
I suspect it'd be more confusing than ergonomic.
The iterator has to mutably borrow the scope. That means you can't really do anything with the values except collect() them but I bet that won't be obvious to most people.
You're welcome to send a pull request, though. Who knows, maybe I'm overthinking this.
I agree with Ben here and would prefer to stick to V8 API here, it's a bit cumbersome to work with V8 arrays but it's manageable.