summaryrefslogtreecommitdiffstats
path: root/src/history.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-11-11 03:20:55 -0500
committerJesse Luehrs <doy@tozt.net>2021-11-11 03:20:55 -0500
commit57a9e97dcab66c9f13331280335841b3d098b0b5 (patch)
treef88ba9ad5ddef8b7c3464bb0a8535190c331444d /src/history.rs
parentfde3881053377bd63d7ca08d0604e6ca87860b9c (diff)
downloadnbsh-57a9e97dcab66c9f13331280335841b3d098b0b5.tar.gz
nbsh-57a9e97dcab66c9f13331280335841b3d098b0b5.zip
switch to futures-lite
Diffstat (limited to 'src/history.rs')
-rw-r--r--src/history.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/history.rs b/src/history.rs
index 3586a3c..50e5ca7 100644
--- a/src/history.rs
+++ b/src/history.rs
@@ -34,12 +34,16 @@ impl History {
let task_action = self.action.clone();
async_std::task::spawn(async move {
loop {
+ enum Res {
+ Read(Result<usize, std::io::Error>),
+ Write(Result<Vec<u8>, async_std::channel::RecvError>),
+ }
let mut buf = [0_u8; 4096];
let mut pty = child.pty();
- let read = pty.read(&mut buf);
- let write = input_r.recv();
- match futures::future::select(read, write).await {
- futures::future::Either::Left((res, _)) => {
+ let read = async { Res::Read(pty.read(&mut buf).await) };
+ let write = async { Res::Write(input_r.recv().await) };
+ match futures_lite::future::race(read, write).await {
+ Res::Read(res) => {
match res {
Ok(bytes) => {
task_entry
@@ -67,7 +71,7 @@ impl History {
.await
.unwrap();
}
- futures::future::Either::Right((res, _)) => match res {
+ Res::Write(res) => match res {
Ok(bytes) => {
pty.write(&bytes).await.unwrap();
}