Do any workarounds exist for the following borrow checker issue?
⚓ Rust 📅 2025-09-27 👤 surdeus 👁️ 8I ran into this problem and I'm quite sure the is not a mistake on my end but a shortcoming in the borrow checker.
type Key = (); // todo! will become a kind of keyboard input result, like a char
type Action<T> = for <'a> fn(<T as Scene>::ActionArg<'a>) -> <T as Scene>::ActionRes;
trait Scene
{
    type CursorPosition;
    type ActionArg<'this>;
    type ActionRes;
    fn getPossibleActions(cursor : Self::CursorPosition) -> &'static [(Key, Action<Self>)];
}
This does not compile because of getPossibleActions. To me, it seems like a perfectly reasonable thing to ask without restricting Self to 'static, which the compiler is now asking me to do. In fact, I am certain that Self is not restricted to 'static.
Is there a way to fix this without giving CursorPosition a generic associated lifetime?
3 posts - 3 participants
🏷️ Rust_feed