private function writeNextElement()
{
$current = $this->iterator->current();
if (!$current instanceof Promise) {
$this->finalizeEventualWriteElement($current);
return;
}
$current->when(function ($error, $result) {
if ($error) {
$this->promisor->fail($error);
} else {
$this->finalizeEventualWriteElement($result);
}
});
}