From 8533d4d8ea1133c713c7e155dcaabccbbe0cecdc Mon Sep 17 00:00:00 2001 From: Jacob Rothstein Date: Tue, 23 Jun 2020 18:36:20 -0700 Subject: [PATCH] fix catflap example for windows --- examples/catflap.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/catflap.rs b/examples/catflap.rs index 15754d333..8532f76a1 100644 --- a/examples/catflap.rs +++ b/examples/catflap.rs @@ -1,5 +1,3 @@ -const CHANGE_THIS_TEXT: &str = "hello world!"; - #[cfg(unix)] #[async_std::main] async fn main() -> Result<(), std::io::Error> { @@ -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(()) } @@ -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 -";