diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b5ed73..dc904d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: steps: - name: checkout source - uses: actions/checkout@v3 + uses: actions/checkout@v7 with: persist-credentials: false @@ -45,7 +45,7 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout source - uses: actions/checkout@v3 + uses: actions/checkout@v7 with: persist-credentials: false @@ -66,7 +66,7 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout source - uses: actions/checkout@v3 + uses: actions/checkout@v7 with: persist-credentials: false diff --git a/Cargo.toml b/Cargo.toml index e085f1e..e699a7e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,3 +18,7 @@ tinyvec = { version = "1.4", features = ["rustc_1_55"] } [features] default = [] alloc = ["hashbrown"] + +[dev-dependencies] +# Keep the MSRV test graph compatible with Rust 1.61. +once_cell = "=1.19.0" diff --git a/src/array_map/iterators.rs b/src/array_map/iterators.rs index 6717d64..c9d2c0b 100644 --- a/src/array_map/iterators.rs +++ b/src/array_map/iterators.rs @@ -83,7 +83,6 @@ impl Iterator for IntoIter { } #[inline] - #[must_use] fn size_hint(&self) -> (usize, Option) { (0, self.inner.size_hint().1) } diff --git a/src/array_map/mod.rs b/src/array_map/mod.rs index d5f0b5a..9016c06 100644 --- a/src/array_map/mod.rs +++ b/src/array_map/mod.rs @@ -176,18 +176,14 @@ impl ArrayMap { fn node_by_key(&self, key: &K) -> Option<&Node> { let mut current = self.root(); loop { - match current { + let val = current?; + let node = self.node_at(val).expect("Invalid node tree"); + current = match node.kv.0.partial_cmp(key) { None => return None, - Some(val) => { - let node = self.node_at(val).expect("Invalid node tree"); - current = match node.kv.0.partial_cmp(key) { - None => return None, - Some(Ordering::Equal) => return Some(node), - Some(Ordering::Less) => node.children[0], - Some(Ordering::Greater) => node.children[1], - }; - } - } + Some(Ordering::Equal) => return Some(node), + Some(Ordering::Less) => node.children[0], + Some(Ordering::Greater) => node.children[1], + }; } } @@ -196,20 +192,16 @@ impl ArrayMap { fn node_by_key_mut(&mut self, key: &K) -> Option<&mut Node> { let mut current = self.root(); loop { - match current { + let val = current?; + let node = self.node_at(val).expect("Invalid node tree"); + current = match node.kv.0.partial_cmp(key) { None => return None, - Some(val) => { - let node = self.node_at(val).expect("Invalid node tree"); - current = match node.kv.0.partial_cmp(key) { - None => return None, - Some(Ordering::Equal) => { - return Some(self.node_at_mut(val).expect("Invalid node tree")); - } - Some(Ordering::Less) => node.children[0], - Some(Ordering::Greater) => node.children[1], - }; + Some(Ordering::Equal) => { + return Some(self.node_at_mut(val).expect("Invalid node tree")); } - } + Some(Ordering::Less) => node.children[0], + Some(Ordering::Greater) => node.children[1], + }; } } @@ -433,10 +425,7 @@ impl ArrayMap { let mut last_relationship = ParentChildRelation::ChildIsRoot; let mut current: Option = self.root; loop { - let c = match current { - Some(c) => c, - None => return None, - }; + let c = current?; let cmp_node = self.node_at(c).expect(ERR_MSG); match cmp_node.kv.0.partial_cmp(key) { None => return None, diff --git a/src/tiny_map.rs b/src/tiny_map.rs index 8cacb1d..2375e91 100644 --- a/src/tiny_map.rs +++ b/src/tiny_map.rs @@ -216,6 +216,13 @@ impl TinyMap { } } +impl Default for TinyMap { + #[inline] + fn default() -> Self { + Self::new() + } +} + impl IntoIterator for TinyMap { type Item = (K, V); type IntoIter = IntoIter;