From b10a24e112a291a5bee948dacc185bb8fbdf3182 Mon Sep 17 00:00:00 2001 From: Ticki Date: Thu, 17 Mar 2016 17:12:47 +0100 Subject: [PATCH] Remove 'into_async', use 'async_stdin' instead --- src/input.rs | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/src/input.rs b/src/input.rs index 1f207d2..754823e 100644 --- a/src/input.rs +++ b/src/input.rs @@ -1,8 +1,6 @@ use std::io::{self, Read, Write}; -use std::thread; -use std::sync::mpsc; -use {IntoRawMode, AsyncReader}; +use IntoRawMode; #[cfg(feature = "nightly")] use std::io::{Chars, CharsError}; @@ -87,11 +85,6 @@ pub trait TermRead { /// EOT and ETX will abort the prompt, returning `None`. Newline or carriage return will /// complete the password input. fn read_passwd(&mut self, writer: &mut W) -> io::Result>; - - /// Turn the reader into a asynchronous reader. - /// - /// This will spawn up another thread listening for event, buffering them in a mpsc queue. - fn into_async(self) -> AsyncReader where Self: Send; } impl TermRead for R { @@ -119,28 +112,6 @@ impl TermRead for R { Ok(Some(passwd)) } - - fn into_async(self) -> AsyncReader where R: Send + 'static { - let (send, recv) = mpsc::channel(); - - thread::spawn(move || { - let mut reader = self; - loop { - let mut buf = [0]; - if send.send(if let Err(k) = reader.read(&mut buf) { - Err(k) - } else { - Ok(buf[0]) - }).is_err() { - return; - }; - } - }); - - AsyncReader { - recv: recv, - } - } } #[cfg(test)]