Closed
Description
The iter module has lots of handy stuff, but afaict there's no built-in way to iterate over numeric ranges. One thing that would be helpful is if, uint at least, had an impl something like
impl of iter::base_iter<uint> for uint
{
fn each(blk: fn(&&uint) -> bool)
{
let mut i = 0u;
while i < self
{
if (!blk(i))
{
ret;
}
i += 1u;
}
}
fn size_hint() -> option<uint>
{
option::some(self)
}
}
Even better would be a real range type. They seem to be a nice abstraction for collections and algorithms and they would make it simpler to iterate over ranges with non-zero lower bounds.