From 4d2b9670b126b2c9be9cd560a8ea31ede1aa6042 Mon Sep 17 00:00:00 2001 From: bigduu Date: Mon, 15 Jan 2024 12:39:50 +0800 Subject: [PATCH] Fix sec-3-address.md run failed issue (#357) The example run failed with below issue ``` `spawn_local` called from outside of a `task::LocalSet` note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ``` --- docs/actix/sec-3-address.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/actix/sec-3-address.md b/docs/actix/sec-3-address.md index f25bc1f..0a8723f 100644 --- a/docs/actix/sec-3-address.md +++ b/docs/actix/sec-3-address.md @@ -145,14 +145,14 @@ impl Handler for SmsSubscriber { } -fn main() { - let system = System::new("events"); - let email_subscriber = Subscribe(EmailSubscriber{}.start().recipient()); - let sms_subscriber = Subscribe(SmsSubscriber{}.start().recipient()); +#[actix::main] +async fn main() -> Result<(), actix::MailboxError> { + let email_subscriber = Subscribe(EmailSubscriber {}.start().recipient()); + let sms_subscriber = Subscribe(SmsSubscriber {}.start().recipient()); let order_event = OrderEvents::new().start(); - order_event.do_send(email_subscriber); - order_event.do_send(sms_subscriber); - order_event.do_send(Ship(1)); - system.run(); + order_event.send(email_subscriber).await?; + order_event.send(sms_subscriber).await?; + order_event.send(Ship(1)).await?; + Ok(()) } ```