actor_own_anon/
actor_own_anon.rs1use stakker::*;
5use std::time::Instant;
6
7struct Cat;
8impl Cat {
9 fn init(_: CX![]) -> Option<Self> {
10 Some(Self)
11 }
12 fn sound(&mut self, _: CX![]) {
13 println!("Miaow");
14 }
15}
16
17struct Dog;
18impl Dog {
19 fn init(_: CX![]) -> Option<Self> {
20 Some(Self)
21 }
22 fn sound(&mut self, _: CX![]) {
23 println!("Woof");
24 }
25}
26
27pub fn call_and_drop(sound: Fwd<()>, _own: ActorOwnAnon) {
30 fwd!([sound]);
31}
32
33fn main() {
34 let mut stakker = Stakker::new(Instant::now());
35 let s = &mut stakker;
36
37 let cat = actor!(s, Cat::init(), ret_nop!());
38 call_and_drop(fwd_to!([cat], sound() as ()), cat.anon());
39
40 let dog = actor!(s, Dog::init(), ret_nop!());
41 call_and_drop(fwd_to!([dog], sound() as ()), dog.anon());
42
43 s.run(Instant::now(), false);
44}