1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
use crate::*;
use Any;
/// Holds a [`MessageSpecifier::Payload`]
;
// #[cfg(test)]
// mod test {
// use super::*;
// #[test]
// fn boxed_msg() {
// struct Msg1;
// struct Msg2;
// impl Message for Msg1 {
// type Payload = Self;
// type Returned = ();
// fn into_payload(self) -> (Self::Payload, Self::Returned) {
// (self, ())
// }
// fn from_payload(sent: Self::Payload, _returned: Self::Returned) -> Self {
// sent
// }
// }
// impl Message for Msg2 {
// type Payload = Self;
// type Returned = ();
// fn into_payload(self) -> (Self::Payload, Self::Returned) {
// (self, ())
// }
// fn from_payload(sent: Self::Payload, _returned: Self::Returned) -> Self {
// sent
// }
// }
// let boxed = AnyPayload::new::<Msg1>(Msg1);
// assert!(boxed.downcast::<Msg1>().is_ok());
// let boxed = AnyPayload::new::<Msg1>(Msg1);
// assert!(boxed.downcast::<Msg2>().is_err());
// }
// }