diff options
Diffstat (limited to 'std/default/iterators.pk')
-rw-r--r-- | std/default/iterators.pk | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/std/default/iterators.pk b/std/default/iterators.pk deleted file mode 100644 index f7e4972..0000000 --- a/std/default/iterators.pk +++ /dev/null @@ -1,38 +0,0 @@ -## std/iterators: The Iter interface and associated functions. -## This module is imported by default. - -## The Iter interface. Any type implementing `next()` is iterable. -pub type Iter[T] = interface - next(mut Self): Option[T] - -# todo: useful functions for an iterator -# https://doc.rust-lang.org/std/iter/trait.Iterator.html#provided-methods - -pub func advance_by[T](self: Iter[T], n: uint): Result[T, ...] = - for i in 0 .. n: - if self.next().is_none(): - return Error(...) - Okay - -pub func get[T](self: Iter[T], at: uint): Option[T] - self.advance_by(at-1).ok? - self.next() - -# todo: implement iter[T](self: ...): Iter[T] funcs -# todo: efficient functional methods - -## The Peek interface. Any type implementing `Iter`, `peek`, and `peek_nth` is peekable. -pub type Peek[T] = interface - next(mut Self): Option[T] - peek(mut Self): Option[T] - peek_nth(mut Self, int): Option[T] - -# todo: implement peek[T](self: Iter[T]): Peek[T] -# todo: implement Peekable struct -# https://github.com/LukeMathWalker/multipeek/blob/main/src/lib.rs - -## We don't want a Countable. It's not terribly useful. -# pub type Countable[T] = interface -# next(mut Self): Option[T] -# len(Self): uint -# get(Self, uint): Option[T] |