Skip to content

Commit

Permalink
Merge pull request #315 from tomaka/size_hint
Browse files Browse the repository at this point in the history
Redirect size_hint method to the underlying iterators
  • Loading branch information
tomaka committed Mar 16, 2015
2 parents b431ef5 + daa0867 commit b4f8c3b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,19 +445,29 @@ pub struct PollEventsIterator<'a>(winimpl::PollEventsIterator<'a>);

impl<'a> Iterator for PollEventsIterator<'a> {
type Item = Event;

fn next(&mut self) -> Option<Event> {
self.0.next()
}

fn size_hint(&self) -> (usize, Option<usize>) {
self.0.size_hint()
}
}

/// An iterator for the `wait_events` function.
pub struct WaitEventsIterator<'a>(winimpl::WaitEventsIterator<'a>);

impl<'a> Iterator for WaitEventsIterator<'a> {
type Item = Event;

fn next(&mut self) -> Option<Event> {
self.0.next()
}

fn size_hint(&self) -> (usize, Option<usize>) {
self.0.size_hint()
}
}

/// An iterator for the list of available monitors.
Expand All @@ -469,9 +479,14 @@ pub struct AvailableMonitorsIter {

impl Iterator for AvailableMonitorsIter {
type Item = MonitorID;

fn next(&mut self) -> Option<MonitorID> {
self.data.next().map(|id| MonitorID(id))
}

fn size_hint(&self) -> (usize, Option<usize>) {
self.data.size_hint()
}
}

/// Returns the list of all available monitors.
Expand Down

0 comments on commit b4f8c3b

Please sign in to comment.