Minor cosmetic changes

This commit is contained in:
Ticki 2016-03-09 11:38:43 +01:00
parent 543b2f8975
commit 0efce912d0
2 changed files with 9 additions and 10 deletions

View File

@ -22,8 +22,8 @@ fn main() {
Key::Alt(c) => println!("^{}", c), Key::Alt(c) => println!("^{}", c),
Key::Left => println!(""), Key::Left => println!(""),
Key::Right => println!(""), Key::Right => println!(""),
Key::Up => println!(""), Key::Up => println!(""),
Key::Down => println!(""), Key::Down => println!(""),
Key::Backspace => println!("×"), Key::Backspace => println!("×"),
Key::Invalid => println!("???"), Key::Invalid => println!("???"),
Key::Error => println!("ERROR"), Key::Error => println!("ERROR"),

View File

@ -1,8 +1,8 @@
use std::io::{Read, Write}; use std::io::{self, Read, Write};
use {IntoRawMode, TerminalError}; use {IntoRawMode, TerminalError};
#[cfg(feature = "nightly")] #[cfg(feature = "nightly")]
use std::io::Chars; use std::io::{Chars, CharsError};
/// A key. /// A key.
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
@ -28,14 +28,13 @@ pub enum Key {
Error, Error,
} }
#[cfg(feature = "nightly")]
/// An iterator over input keys. /// An iterator over input keys.
pub struct Keys<R> { pub struct Keys<I> {
chars: Chars<R>, chars: I,
} }
#[cfg(feature = "nightly")] #[cfg(feature = "nightly")]
impl<R: Read> Iterator for Keys<R> { impl<I: Iterator<Item = Result<char, CharsError>>> Iterator for Keys<I> {
type Item = Key; type Item = Key;
fn next(&mut self) -> Option<Key> { fn next(&mut self) -> Option<Key> {
@ -63,7 +62,7 @@ impl<R: Read> Iterator for Keys<R> {
pub trait TermRead { pub trait TermRead {
/// An iterator over key inputs. /// An iterator over key inputs.
#[cfg(feature = "nightly")] #[cfg(feature = "nightly")]
fn keys(self) -> Keys<Self> where Self: Sized; fn keys(self) -> Keys<Chars<Self>> where Self: Sized;
/// Read a password. /// Read a password.
/// ///
@ -74,7 +73,7 @@ pub trait TermRead {
impl<R: Read> TermRead for R { impl<R: Read> TermRead for R {
#[cfg(feature = "nightly")] #[cfg(feature = "nightly")]
fn keys(self) -> Keys<R> { fn keys(self) -> Keys<Chars<R>> {
Keys { Keys {
chars: self.chars(), chars: self.chars(),
} }