Struct js::jsapi::ForOfIterator
[−]
[src]
#[repr(C)]pub struct ForOfIterator { pub cx_: *mut JSContext, pub iterator: RootedObject, pub index: u32, }
Convenience class for imitating a JS level for-of loop. Typical usage:
ForOfIterator it(cx); if (!it.init(iterable)) return false; RootedValue val(cx); while (true) { bool done; if (!it.next(&val, &done)) return false; if (done) break; if (!DoStuff(cx, val)) return false; }
Fields
cx_: *mut JSContext
iterator: RootedObject
index: u32
Methods
impl ForOfIterator
[src]
pub unsafe fn init(
&mut self,
iterable: HandleValue,
nonIterableBehavior: ForOfIterator_NonIterableBehavior
) -> bool
[src]
&mut self,
iterable: HandleValue,
nonIterableBehavior: ForOfIterator_NonIterableBehavior
) -> bool
Initialize the iterator. If AllowNonIterable is passed then if getting the @@iterator property from iterable returns undefined init() will just return true instead of throwing. Callers must then check valueIsIterable() before continuing with the iteration.
pub unsafe fn next(&mut self, val: MutableHandleValue, done: *mut bool) -> bool
[src]
Get the next value from the iterator. If false *done is true after this call, do not examine val.