Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
persist-credentials: false

- name: install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1.3.5
uses: actions-rust-lang/setup-rust-toolchain@v1.17.0
with:
toolchain: ${{ matrix.version }}

Expand All @@ -50,7 +50,7 @@ jobs:
persist-credentials: false

- name: install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1.3.5
uses: actions-rust-lang/setup-rust-toolchain@v1.17.0
with: { components: rustfmt, clippy }

- name: format
Expand All @@ -71,7 +71,7 @@ jobs:
persist-credentials: false

- name: install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1.3.5
uses: actions-rust-lang/setup-rust-toolchain@v1.17.0
with: { toolchain: nightly }

- name: install cargo-hack
Expand Down
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
1 change: 0 additions & 1 deletion src/array_map/iterators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ impl<K, V, const N: usize> Iterator for IntoIter<K, V, N> {
}

#[inline]
#[must_use]
fn size_hint(&self) -> (usize, Option<usize>) {
(0, self.inner.size_hint().1)
}
Expand Down
43 changes: 16 additions & 27 deletions src/array_map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,14 @@ impl<K: PartialOrd, V, const N: usize> ArrayMap<K, V, N> {
fn node_by_key(&self, key: &K) -> Option<&Node<K, V>> {
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],
};
}
}

Expand All @@ -196,20 +192,16 @@ impl<K: PartialOrd, V, const N: usize> ArrayMap<K, V, N> {
fn node_by_key_mut(&mut self, key: &K) -> Option<&mut Node<K, V>> {
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],
};
}
}

Expand Down Expand Up @@ -433,10 +425,7 @@ impl<K: PartialOrd, V, const N: usize> ArrayMap<K, V, N> {
let mut last_relationship = ParentChildRelation::ChildIsRoot;
let mut current: Option<usize> = 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,
Expand Down
7 changes: 7 additions & 0 deletions src/tiny_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,13 @@ impl<K: PartialOrd + Eq + Hash, V, const N: usize> TinyMap<K, V, N> {
}
}

impl<K: PartialOrd + Eq + Hash, V, const N: usize> Default for TinyMap<K, V, N> {
#[inline]
fn default() -> Self {
Self::new()
}
}

impl<K: PartialOrd + Eq + Hash, V, const N: usize> IntoIterator for TinyMap<K, V, N> {
type Item = (K, V);
type IntoIter = IntoIter<K, V, N>;
Expand Down
Loading