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

Methods

impl ForOfIterator
[src]

[src]

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.

[src]

Get the next value from the iterator. If false *done is true after this call, do not examine val.

Trait Implementations

impl Debug for ForOfIterator
[src]

[src]

Formats the value using the given formatter.