The type parameter may not live long enough + sync::mpsc::Sender

Hello,

I have a problem while using generics and std::sync::mpsc::{Sender, Receiver} , and I wonder if someone can explain me better my error?

Here is my problem: Rust Playground

I don't understand why this lifetime is asked, because the "Sender" struct is Send, whatever is the type inside? Is that a limitation of generics + Sender/Receiver?

Thank you in advance,
Denis

The Box is what's forcing you here, as it defaults to 'static. You could add a lifetime like this:

impl<'a, T: 'a> A<Sender<T>> {
    fn de(self) -> Box<dyn Test + 'a> {
        Box::new(self)
    }
}
2 Likes