public static function size(Iterator $iterator)
    {
        $result = 0;
        Iterators::each($iterator, function () use (&$result) {
            $result++;
        });
        return $result;
    }