Skip to content

Commit

Permalink
Fix non-empty rbtree infinite iteration, bump version to 0.10.7 (and …
Browse files Browse the repository at this point in the history
…no, I won't test it locally)
  • Loading branch information
MrElectrify committed Mar 7, 2024
1 parent e3e538f commit d3e6feb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "eastl-rs"
authors = ["Andrew Buck"]
description = "EASTL binary-compatible Rust implementations"
documentation = "https://docs.rs/crate/eastl-rs"
version = "0.10.6"
version = "0.10.7"
edition = "2021"
license-file = "LICENSE"
readme = "README.md"
Expand Down
14 changes: 11 additions & 3 deletions src/internal/rb_tree/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::ptr;

/// An iterator over a Red-Black tree's nodes.
pub struct Iter<'a, K, V> {
pub(super) node: *mut Node<K, V>,
pub(super) node: *const Node<K, V>,
pub(super) anchor: *const (),
pub(super) _marker: PhantomData<&'a ()>,
}
Expand All @@ -25,7 +25,11 @@ impl<'a, K: 'a, V: 'a> Iterator for Iter<'a, K, V> {

unsafe { self.node.as_ref() }
.and_then(Node::next)
.map(|node| (node.key(), node.val()))
.map(|node| {
// update the iterator
self.node = node;
(node.key(), node.val())
})
}
}

Expand All @@ -39,6 +43,10 @@ impl<'a, K: 'a, V: 'a> Iterator for IterMut<'a, K, V> {

unsafe { self.node.as_mut() }
.and_then(Node::next_mut)
.map(|node| (&node.pair.0, &mut node.pair.1))
.map(|node| {
// update the iterator
self.node = node;
(&node.pair.0, &mut node.pair.1)
})
}
}

0 comments on commit d3e6feb

Please sign in to comment.