-
That will run https://github.com/ctaggart/autorest-rust/blob/stdio/src/main.rs, currently: use tokio::io::{self, AsyncBufReadExt, BufReader};
pub type Error = Box<dyn std::error::Error + Send + Sync>;
pub type Result<T> = std::result::Result<T, Error>;
#[tokio::main]
pub async fn main() -> Result<()> {
let stdin = io::stdin();
let mut lines = BufReader::new(stdin).lines();
while let Some(line) = lines.next_line().await? {
println!("length = {}", line.len());
}
Ok(())
} It waits for lines from stdin and then prints the length of each line passed in. The problem is when I try to run it with wasi, I get
|
Beta Was this translation helpful? Give feedback.
Answered by
Darksonn
Aug 9, 2020
Replies: 2 comments
-
My workaround is to not use async or tokio. use std::{io, io::prelude::*};
pub type Error = Box<dyn std::error::Error + Send + Sync>;
pub type Result<T> = std::result::Result<T, Error>;
pub fn main() -> Result<()> {
for line in io::stdin().lock().lines() {
println!("length = {}", line?.len());
}
Ok(())
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
WASM is currently not a supported platform by Tokio. There is a large number of unanswered questions before we can support it. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ctaggart
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
WASM is currently not a supported platform by Tokio. There is a large number of unanswered questions before we can support it.