Implement AsyncBufRead for Unblock<T: BufRead>
Keruspe opened this issue · comments
Marc-Antoine Perennou commented
Not sure how hard that would be, but this would make things like std::io::stdin().read_line()
possible
Deleted user commented
Hmm, but Stdin
does not implement BufRead
, does it?
So I suppose we need to wrap it in BufReader
in one of the following two ways:
BufReader::new(Unblock::new(std::io::stdin())).read_line()
Unblock::new(BufReader::new(std::io::stdin())).read_line()
Marc-Antoine Perennou commented
I ended up doing
let mut input = blocking::unblock(|| {
let mut input = String::new();
std::io::stdin().read_line(&mut input).map(|_| input)
})
.await
.unwrap();
this is fine enough, let's close this