aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
authortomaka <pierre.krieger1708@gmail.com>2015-02-10 22:34:18 +0100
committertomaka <pierre.krieger1708@gmail.com>2015-02-10 22:34:18 +0100
commit4500702a0294065f876ca10e7629fd32e213ca76 (patch)
tree0bf6f0f1580345f6441765e6e74cc64bcaf7e79a /src/lib.rs
parent605bd37554655436841e4cd2c4fbb3d046de2330 (diff)
parent95b1c96181e538004800942ae8ab07a81ec49454 (diff)
downloadglutin-4500702a0294065f876ca10e7629fd32e213ca76.tar.gz
glutin-4500702a0294065f876ca10e7629fd32e213ca76.zip
Merge pull request #70 from tomaka/fix-iterators
Use platform-specific iterators instead
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs34
1 files changed, 6 insertions, 28 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 85d373a..49c7474 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -592,7 +592,7 @@ impl Window {
/// Contrary to `wait_events`, this function never blocks.
#[inline]
pub fn poll_events(&self) -> PollEventsIterator {
- PollEventsIterator { window: self, data: self.window.poll_events().into_iter() }
+ PollEventsIterator(self.window.poll_events())
}
/// Returns an iterator that returns events one by one, blocking if necessary until one is
@@ -601,7 +601,7 @@ impl Window {
/// The iterator never returns `None`.
#[inline]
pub fn wait_events(&self) -> WaitEventsIterator {
- WaitEventsIterator { window: self, data: self.window.wait_events().into_iter() }
+ WaitEventsIterator(self.window.wait_events())
}
/// Sets the context as the current context.
@@ -754,24 +754,13 @@ impl gl_common::GlFunctionsSource for HeadlessContext {
// Implementation note: we retreive the list once, then serve each element by one by one.
// This may change in the future.
#[cfg(feature = "window")]
-pub struct PollEventsIterator<'a> {
- window: &'a Window,
- data: RingBufIter<Event>,
-}
+pub struct PollEventsIterator<'a>(winimpl::PollEventsIterator<'a>);
#[cfg(feature = "window")]
impl<'a> Iterator for PollEventsIterator<'a> {
type Item = Event;
fn next(&mut self) -> Option<Event> {
- if let Some(ev) = self.data.next() {
- return Some(ev);
- }
-
- let PollEventsIterator { window, data } = self.window.poll_events();
- self.window = window;
- self.data = data;
-
- self.data.next()
+ self.0.next()
}
}
@@ -779,24 +768,13 @@ impl<'a> Iterator for PollEventsIterator<'a> {
// Implementation note: we retreive the list once, then serve each element by one by one.
// This may change in the future.
#[cfg(feature = "window")]
-pub struct WaitEventsIterator<'a> {
- window: &'a Window,
- data: RingBufIter<Event>,
-}
+pub struct WaitEventsIterator<'a>(winimpl::WaitEventsIterator<'a>);
#[cfg(feature = "window")]
impl<'a> Iterator for WaitEventsIterator<'a> {
type Item = Event;
fn next(&mut self) -> Option<Event> {
- if let Some(ev) = self.data.next() {
- return Some(ev);
- }
-
- let WaitEventsIterator { window, data } = self.window.wait_events();
- self.window = window;
- self.data = data;
-
- self.next()
+ self.0.next()
}
}