- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Labels
C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.
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.
Metadata
Metadata
Assignees
Labels
C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.