Created
February 26, 2013 20:18
-
-
Save ben0x539/5041766 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait InputRange<T> { | |
pure fn is_empty(&self) -> bool; | |
pure fn head(&self) -> &self/T; | |
pure fn tail(&self) -> Self; | |
} | |
pure fn each<T, U: InputRange<T>>(range: U, blk: fn(v: &T) -> bool) { | |
while !range.is_empty() && blk(range.head()) { | |
range = range.tail(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment