Skip to content

Commit

Permalink
Add docs for terminal::{EventIterator, events}.
Browse files Browse the repository at this point in the history
Tops off and closes #2
  • Loading branch information
nabijaczleweli committed Jan 14, 2016
1 parent fc81f1c commit ba0dd08
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/terminal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ pub fn wait_event() -> Option<Event> {
to_event(ffi::read())
}

/// Returns an instance of [`EventIterator`](struct.EventIterator.html), an infinite iterator over Terminal events.
pub fn events() -> EventIterator {
EventIterator
}
Expand Down Expand Up @@ -269,6 +270,27 @@ pub fn delay(period: i32) {
}


/// Infinite iterator over Terminal events, instantiated by [`events()`](fn.events.html).
///
/// Yields `None` iff BLT is closed.
///
/// # Examples
///
/// The "standard" way:
///
/// ```ignore
/// while let Some(event) = terminal::wait_event() {
/// // ...
/// }
/// ```
///
/// Is equivalent to, but not as good as:
///
/// ```ignore
/// for event in terminal::events() {
/// // ...
/// }
/// ```
pub struct EventIterator;

impl Iterator for EventIterator {
Expand Down

0 comments on commit ba0dd08

Please sign in to comment.