Define a trait with a function that returns an associated type with the same lifetime as one parameter
问题 I'm trying to define a trait with a function that returns an associated type with the same lifetime as one parameter. Conceptually something like the following (which doesn't work: lifetime parameter not allowed on this type [Self::Output] ): trait Trait { type Output; fn get_output<'a>(&self, input: &'a i32) -> Self::Output<'a>; } I found several questions about lifetimes for associated types on Stack Overflow and the Internet, but none seem to help. Some suggested defining the lifetime on