1
0
mirror of https://github.com/actix/actix-website synced 2024-11-24 00:41:07 +01:00

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
```
This commit is contained in:
bigduu 2024-01-15 12:39:50 +08:00 committed by GitHub
parent 8c33e4bf35
commit 4d2b9670b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -145,14 +145,14 @@ impl Handler<OrderShipped> 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(())
}
```