Your issue may already be reported! Please search on the Actix issue tracker before creating one.
Current Behavior
error[E0433]: failed to resolve: could not find __private in actix
--> 33_concurrency/examples/actor.rs:40:1
|
40 | #[actix::main]
| ^^^^^^^^^^^^^^ could not find __private in actix
Steps to Reproduce (for bugs)
use actix::prelude::*;
use anyhow::Result;
// actor 可以处理的消息
#[derive(Message, Debug, Clone, PartialEq)]
#[rtype(result = "OutMsg")]
enum InMsg {
Add((usize, usize)),
Concat((String, String)),
}
#[derive(MessageResponse, Debug, Clone, PartialEq)]
enum OutMsg {
Num(usize),
Str(String),
}
// Actor
struct DummyActor;
impl Actor for DummyActor {
type Context = Context<Self>;
}
// 实现处理 InMsg 的 Handler trait
impl Handler<InMsg> for DummyActor {
type Result = OutMsg; // <- 返回的消息
fn handle(&mut self, msg: InMsg, _ctx: &mut Self::Context) -> Self::Result {
match msg {
InMsg::Add((a, b)) => OutMsg::Num(a + b),
InMsg::Concat((mut s1, s2)) => {
s1.push_str(&s2);
OutMsg::Str(s1)
}
}
}
}
#[actix::main]
async fn main() -> Result<()> {
let addr = DummyActor.start();
let res = addr.send(InMsg::Add((21, 21))).await?;
let res1 = addr
.send(InMsg::Concat(("hello, ".into(), "world".into())))
.await?;
println!("res: {:?}, res1: {:?}", res, res1);
Ok(())
}
Your Environment
Rust Version (I.e, output of rustc -V):rustc 1.78.0 (9b00956e5 2024-04-29)
Your issue may already be reported! Please search on the Actix issue tracker before creating one.
Current Behavior
error[E0433]: failed to resolve: could not find
__private
inactix
--> 33_concurrency/examples/actor.rs:40:1 | 40 | #[actix::main] | ^^^^^^^^^^^^^^ could not find__private
inactix
Steps to Reproduce (for bugs)
Your Environment
rustc -V
):rustc 1.78.0 (9b00956e5 2024-04-29)