Self reference struct

Let's say I have a struct

struct Foo<'a> {
    a: Boo,
    b: &'a Boo,
}

How do I make it work?

If you must [1], then it can be done with the help of crates like this: self_referencing in ouroboros - Rust


  1. though often its also fairly straightforward to avoid the need for self-references in the first place, in wich case doing so might be the preferred and more straightforward approach ↩ī¸Ž

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.