use scrappy_actor::{Actor, Context, Handler, System}; use scrappy_derive::{Message, MessageResponse}; #[derive(MessageResponse)] struct Added(usize); #[derive(Message)] #[rtype(result = "Added")] struct Sum(usize, usize); #[derive(Default)] struct Adder; impl Actor for Adder { type Context = Context; } impl Handler for Adder { type Result = ::Result; fn handle(&mut self, msg: Sum, _: &mut Self::Context) -> Added { Added(msg.0 + msg.1) } } #[test] fn test_message() { let mut sys = System::new("scrappy-test-runtime"); let addr = Adder::start_default(); let res = sys.block_on(addr.send(Sum(3, 5))).unwrap(); assert_eq!(res.0, 8); }