I have the following code:
use serde::*;
#[derive(Serialize, Deserialize)]
struct B {}
#[derive(Serialize, Deserialize)]
struct A<'a, T> {
t: &'a Pin<Box<T>
}
impl<'a> A<'a, B> {
async fn handle(&'a self, context: Context, event: Event)
-> Result<&'a Self> {
/// ...
OK(self)
}
}
fn main() {
let b: Pin<Box<B> = Box::pin( B{} );
let a = A::<'static, B> { t: &b };
let id = some_actor_system
.spawn()
.with(a, Pin::<Box::<A<'static, B>>>handle).unwrap();
}
Compilation generates the following error:
error[E0277]: the trait bound `&std::pin::Pin<std::boxed::Box<B>>: std::default::Default` is not satisfied
--> src/tests/hsm_03.rs:33:5
|
33 | / /// State processor.
34 | | sm: &'a Pin<Box<SM>>,
| |________________________^ the trait `std::default::Default` is not implemented for `&std::pin::Pin<std::boxed::Box<B>>`
|
= note: required by `std::default::Default::default`
The &'a Pin<Box<SM>>
value is just a pinned reference to some space on the heap; it can't be that difficult to serialize it but I can't get it done... Help appreciated!