oxc/crates/oxc_allocator
overlookmotel eb25bc0ec6 fix(allocator): fix lifetimes on IntoIterator for Vec (#8388)
Lifetime on our impl of `IntoIterator` for `&Vec` was wrong.

Previously:

```rs
impl<'alloc, T> IntoIterator for &'alloc Vec<'alloc, T> {
    type IntoIter = std::slice::Iter<'alloc, T>;
    type Item = &'alloc T;
    fn into_iter(self) -> Self::IntoIter { self.0.iter() }
}
```

This means that the iterator borrows the `Vec` for the lifetime of the allocator, which is way too long. It should only borrow it for the lifetime of the reference `&Vec`. Insisting we borrow the `Vec` for so long to iterate over it was unnecessarily restrictive.

Instead:

```rs
impl<'i, T> IntoIterator for &'i Vec<'_, T> {
    type IntoIter = std::slice::Iter<'i, T>;
    type Item = &'i T;
    fn into_iter(self) -> Self::IntoIter { self.0.iter() }
}
```

This matches the lifetimes on [`allocator_api2::vec::Vec`'s implementation](63cd7fcc2f/src/stable/vec/mod.rs (L2682-L2690)).
2025-01-09 15:32:15 +00:00
..
src fix(allocator): fix lifetimes on IntoIterator for Vec (#8388) 2025-01-09 15:32:15 +00:00
Cargo.toml release(crates): v0.44.0 (#8110) 2024-12-25 21:03:09 +08:00
CHANGELOG.md release(crates): v0.43.0 (#8054) 2024-12-21 15:07:21 +08:00