You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Decouple next lifetime from itself in TaggedStructure::push() and ::extend() (#1005)
Right now `TaggedStructure::push()` is defined by #994 as:
```rs
fn push<T: Extends<Self> + TaggedStructure<'a>>(mut self, next: &'a mut T) -> Self
```
This requires that the extending structure `next` has the same lifetime
as the contents of the base structure `self: TaggedStructure<'a>`
because of `next: &'a mut T`, _and `next` itself_ because of `T:
TaggedStructure<'a>` which is unnecessarily restricting. Specifically,
even after `self` is no longer live (i.e. it is no longer mutably
borrowing `next`) `next` cannot be accessed because it is mutably
borrowed within itself through the fixed/shared lifetime of `'a` as
demonstrated by a new test in commit 4942dc3. The same restriction
exists for `TaggedStructure::extend()`.
This PR decouples lifetime `'a` for the contents of `self` and the
borrow of `next` from a new lifetime `'b` for _the contents of `next`_
in `push()` and `extend()` to require that the _contents of `next`_
outlive the borrow of `next` rather than considering `next` to remain
mutably borrowed within itself.
0 commit comments