code: public static function size(Iterator $iterator)
      {
          $result = 0;
          Iterators::each($iterator, function () use (&$result) {
              $result++;
          });
          return $result;
      }
docs: Returns the number of elements in iterator.
  
  @param Iterator $iterator
  @return int