-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ac27530
commit c3aa484
Showing
2 changed files
with
156 additions
and
307 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
use futures::executor::block_on; | ||
use futures::{channel::mpsc::unbounded, sink::unfold}; | ||
use futures::{channel::mpsc::unbounded, executor::block_on, sink::unfold as sink}; | ||
use lib::uci::Uci; | ||
use std::io::{prelude::*, stdin, stdout}; | ||
use std::{future::ready, thread}; | ||
|
||
fn main() { | ||
let (tx, rx) = unbounded(); | ||
let (tx, input) = unbounded(); | ||
|
||
thread::spawn(move || { | ||
for line in stdin().lock().lines() { | ||
if tx.unbounded_send(line.unwrap()).is_err() { | ||
let mut lines = stdin().lock().lines(); | ||
while let Some(Ok(line)) = lines.next() { | ||
if tx.unbounded_send(line).is_err() { | ||
break; | ||
} | ||
} | ||
}); | ||
|
||
let mut stdout = stdout().lock(); | ||
let output = unfold((), |_, line: String| ready(writeln!(stdout, "{line}"))); | ||
block_on(Uci::new(rx, output).run()).unwrap(); | ||
let output = sink((), |_, line: String| ready(writeln!(stdout, "{line}"))); | ||
block_on(Uci::new(input, output).run()).unwrap(); | ||
} |
Oops, something went wrong.