From da4afa8ae3afec4cd59b9a19ae1e04818f1763a7 Mon Sep 17 00:00:00 2001 From: mat Date: Mon, 4 Dec 2023 20:23:41 -0600 Subject: simplify boilerplate in examples --- azalea/examples/testbot.rs | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'azalea/examples/testbot.rs') diff --git a/azalea/examples/testbot.rs b/azalea/examples/testbot.rs index aa47d5a2..a304e2ce 100644 --- a/azalea/examples/testbot.rs +++ b/azalea/examples/testbot.rs @@ -21,7 +21,7 @@ struct State {} struct SwarmState {} #[tokio::main] -async fn main() -> anyhow::Result<()> { +async fn main() { { use parking_lot::deadlock; use std::thread; @@ -51,20 +51,14 @@ async fn main() -> anyhow::Result<()> { accounts.push(Account::offline(&format!("bot{i}"))); } - loop { - let e = SwarmBuilder::new() - .add_accounts(accounts.clone()) - .set_handler(handle) - .set_swarm_handler(swarm_handle) - .join_delay(Duration::from_millis(100)) - .start("localhost") - .await; - // let e = azalea::ClientBuilder::new() - // .set_handler(handle) - // .start(Account::offline("bot"), "localhost") - // .await; - eprintln!("{e:?}"); - } + SwarmBuilder::new() + .add_accounts(accounts.clone()) + .set_handler(handle) + .set_swarm_handler(swarm_handle) + .join_delay(Duration::from_millis(100)) + .start("localhost") + .await + .unwrap(); } async fn handle(mut bot: Client, event: Event, _state: State) -> anyhow::Result<()> { -- cgit v1.2.3