Skip to content

Commit

Permalink
Merge pull request #30 from SimonSapin/bump-to-1.6.0
Browse files Browse the repository at this point in the history
Bump to 1.6.0
  • Loading branch information
fitzgen authored Sep 12, 2019
2 parents e3a693a + 9550081 commit 89c3ab8
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 27 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Released YYYY/MM/DD.

### Added

* Implement `Default` for `Arena<T>`.
* TODO (or remove section if none)

### Changed

Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "typed-arena"
version = "1.5.0"
version = "1.6.0"
authors = ["Simon Sapin <[email protected]>"]
license = "MIT"
description = "The arena, a fast but limited type of allocator"
Expand Down
1 change: 1 addition & 0 deletions ci/miri.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
46 changes: 24 additions & 22 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
}

Expand Down

0 comments on commit 89c3ab8

Please sign in to comment.