Help: associated type in trait that implements a trait with a lifetime parameter


The associated type should implement the serde::Deserialize trait and own all its data, but I’m getting lifetime errors that make no sense to me when trying to convert a json string into an Output in a function.

pub trait Private<'a> {
    type Output: serde::Deserialize<'a>;


I think you want the following:

pub trait Private {
    // the output type does not need to borrow anything
    type Output: for<'a> serde::Deserialize<'a>;

And this is basically :slight_smile:


Thanks, the DeserializeOwned trait is what I needed here.