How can I implement a struct A which has a field referencing a A with longer lifetime bound?

I want to implement a struct A, which has a field next which references another A which has a longer lifetime. But I found it need infinite lifetime parameters. So any ideas?

struct A<'a, 'b: 'a, 'c: 'b, ...> {
  next: &'a mut A<'b, 'c, ...>
}

You're trying to use temporary scope-bound loans to build a linked list, and it's not possible to do it this way. It's a wrong language feature for lists.

You should use a type of reference that supports shared ownership and isn't temporary, like Arc. See:

1 Like

Thank you for the link! I will try this solution.