Skip to content

Commit

Permalink
fix catflap example for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jbr committed Jun 24, 2020
1 parent eb97d0f commit 8533d4d
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions examples/catflap.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const CHANGE_THIS_TEXT: &str = "hello world!";

#[cfg(unix)]
#[async_std::main]
async fn main() -> Result<(), std::io::Error> {
Expand All @@ -8,10 +6,19 @@ async fn main() -> Result<(), std::io::Error> {
let mut app = tide::new();
app.at("/").get(|_| async { Ok(CHANGE_THIS_TEXT) });

const CHANGE_THIS_TEXT: &str = "hello world!";

const DOCS: &str = "
To run this example:
$ cargo install catflap cargo-watch
$ catflap -- cargo watch -x \"run --example catflap\"
and then edit this file";

if let Some(fd) = env::var("LISTEN_FD").ok().and_then(|fd| fd.parse().ok()) {
app.listen(unsafe { TcpListener::from_raw_fd(fd) }).await?;
} else {
println!("{} {}", DOCS, file!());
println!("{} ({})", DOCS, file!());
}
Ok(())
}
Expand All @@ -20,10 +27,3 @@ async fn main() -> Result<(), std::io::Error> {
fn main() {
panic!("this example only runs on cfg(unix) systems");
}

const DOCS: &str = "to run this example:
$ cargo install catflap cargo-watch
$ catflap -- cargo watch -x \"run --example catflap\"
and then edit
";

0 comments on commit 8533d4d

Please sign in to comment.