Yes, that makes more sense.
The way I see it is not that the compiler is assigning them the same lifetime. It's that the fa = fb
line forces the fa
and fb
to have the same lifetime parameter, and the expression FixObj::new(&ra)
(and the other one) basically "coerces" &ra
to have this shared lifetime that borrows from both ra
and rb
. (although strictly speaking this is not a coercion, but rather assigning a value of a subtype to a supertype).
Shameless plug: I've been writing about this model of lifetimes in a blog series, and will soon be covering lifetime inference.
I believe you can change the macro and API to something safer which truly guarantees that every FixObj has a distinct lifetime. Hang on just a minute...