aboutsummaryrefslogtreecommitdiffstats
path: root/examples/basic.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2022-02-24 02:42:25 -0500
committerJesse Luehrs <doy@tozt.net>2022-02-24 02:50:33 -0500
commit246ae0894d4074c38ea2d2eb520e386b0d36d82d (patch)
treed2e681e4df655a63519193d0b797b09d0afdd4cc /examples/basic.rs
parentcd617e021bed862ac3794cc71123959c8d7d7dd1 (diff)
downloadtextmode-246ae0894d4074c38ea2d2eb520e386b0d36d82d.tar.gz
textmode-246ae0894d4074c38ea2d2eb520e386b0d36d82d.zip
move to tokio
Diffstat (limited to 'examples/basic.rs')
-rw-r--r--examples/basic.rs18
1 files changed, 4 insertions, 14 deletions
diff --git a/examples/basic.rs b/examples/basic.rs
index dce12cc..db56d20 100644
--- a/examples/basic.rs
+++ b/examples/basic.rs
@@ -1,10 +1,10 @@
use textmode::Textmode as _;
#[cfg(feature = "async")]
-async fn run(
- tm: &mut textmode::Output,
- input: &mut textmode::Input,
-) -> textmode::Result<()> {
+#[tokio::main]
+async fn main() -> textmode::Result<()> {
+ let mut input = textmode::Input::new().await?;
+ let mut tm = textmode::Output::new().await?;
tm.move_to(5, 5);
tm.write_str("foo");
input.read_key().await?;
@@ -23,16 +23,6 @@ async fn run(
Ok(())
}
-#[cfg(feature = "async")]
-fn main() {
- smol::block_on(async {
- let mut input = textmode::Input::new().await.unwrap();
- let mut tm = textmode::Output::new().await.unwrap();
- let e = run(&mut tm, &mut input).await;
- e.unwrap();
- });
-}
-
#[cfg(not(feature = "async"))]
fn main() {
let mut tm = textmode::blocking::Output::new().unwrap();