diff --git a/.travis.yml b/.travis.yml index 0acaf5c..0060481 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,14 +2,15 @@ sudo: false language: rust matrix: - include: + allow_failures: + - name: "Miri" + include: - rust: stable - rust: beta - rust: nightly - - rust: nightly os: linux - env: DESCRIPTION="Miri" + name: "Miri" script: - sh ci/miri.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index aa6ff27..91e4bd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ Released YYYY/MM/DD. ### Added -* Implement `Default` for `Arena`. +* TODO (or remove section if none) ### Changed @@ -28,6 +28,18 @@ Released YYYY/MM/DD. -------------------------------------------------------------------------------- +## 1.6.0 + +Released 2019/09/09. + +### Added + +* Added the `Arena::iter_mut` method for mutably iterating over an arena's + contents. [See #29 for + details.](https://github.com/SimonSapin/rust-typed-arena/pull/29) + +-------------------------------------------------------------------------------- + ## 1.5.0 Released 2019/08/02. diff --git a/Cargo.toml b/Cargo.toml index 87ea1ab..123af62 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "typed-arena" -version = "1.5.0" +version = "1.6.0" authors = ["Simon Sapin "] license = "MIT" description = "The arena, a fast but limited type of allocator" diff --git a/ci/miri.sh b/ci/miri.sh index 8873a2c..7e9d748 100644 --- a/ci/miri.sh +++ b/ci/miri.sh @@ -4,6 +4,7 @@ MIRI_NIGHTLY=nightly-$(curl -s https://rust-lang.github.io/rustup-components-his echo "Installing latest nightly with Miri: $MIRI_NIGHTLY" rustup default "$MIRI_NIGHTLY" +cargo clean rustup component add miri cargo miri setup diff --git a/src/lib.rs b/src/lib.rs index fac7c8b..d47550b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -444,32 +444,34 @@ pub struct IterMut<'a, T: 'a> { impl<'a, T> Iterator for IterMut<'a, T> { type Item = &'a mut T; fn next(&mut self) -> Option<&'a mut T> { - match self.state { - IterMutState::ChunkListRest { - mut index, - ref mut inner_iter, - } => { - match inner_iter.next() { - Some(item) => Some(item), - None => { - index += 1; - if index < self.chunks.rest.len() { - let inner_iter = self.chunks.rest[index].iter_mut(); - // Extend the lifetime of the individual elements to that of the arena. - let inner_iter = unsafe { mem::transmute(inner_iter) }; - self.state = IterMutState::ChunkListRest { index, inner_iter }; - self.next() - } else { - let iter = self.chunks.current.iter_mut(); - // Extend the lifetime of the individual elements to that of the arena. - let iter = unsafe { mem::transmute(iter) }; - self.state = IterMutState::ChunkListCurrent { iter }; - self.next() + loop { + match self.state { + IterMutState::ChunkListRest { + mut index, + ref mut inner_iter, + } => { + match inner_iter.next() { + Some(item) => return Some(item), + None => { + index += 1; + if index < self.chunks.rest.len() { + let inner_iter = self.chunks.rest[index].iter_mut(); + // Extend the lifetime of the individual elements to that of the arena. + let inner_iter = unsafe { mem::transmute(inner_iter) }; + self.state = IterMutState::ChunkListRest { index, inner_iter }; + continue; + } else { + let iter = self.chunks.current.iter_mut(); + // Extend the lifetime of the individual elements to that of the arena. + let iter = unsafe { mem::transmute(iter) }; + self.state = IterMutState::ChunkListCurrent { iter }; + continue; + } } } } + IterMutState::ChunkListCurrent { ref mut iter } => return iter.next(), } - IterMutState::ChunkListCurrent { ref mut iter } => iter.next(), } }