rusty_v8 icon indicating copy to clipboard operation
rusty_v8 copied to clipboard

Support a `.iter()` method on `Array`

Open nipunn1313 opened this issue 3 years ago • 1 comments
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> { ... }

nipunn1313 avatar Jan 10 '22 19:01 nipunn1313

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.

bnoordhuis avatar Jan 13 '22 05:01 bnoordhuis

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.

bartlomieju avatar Nov 28 '22 22:11 bartlomieju