The general case is IMO when B
is a Foo<'a>
defined in another crate (and thus cannot be changed). Since the self-referential part of Backed
can only ever be a reference it follows that it cannot work for such structs.
2 Likes
Placement new in a form of super let
would help a lot.
In my experience that's very true and well stated. I have gotten along without this in some cases by using Arc/Rc as workarounds, but this adds overhead (sometimes allocations) where none should be necessary. In other cases I've had to change data structures in ways that makes code more difficult to read and understand.
I also agree with this. It is often said that writing in Rust makes the program strictly better in spite of causing restructuring due to Rust's restrictions. This is often true, but definitely sometimes not true.