Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PatriciaMap::iter has wrong length #21

Closed
jean-airoldie opened this issue Jan 23, 2023 · 6 comments · Fixed by #22
Closed

PatriciaMap::iter has wrong length #21

jean-airoldie opened this issue Jan 23, 2023 · 6 comments · Fixed by #22

Comments

@jean-airoldie
Copy link

jean-airoldie commented Jan 23, 2023

Running the following code:

# Cargo.toml
[package]
name = "patricia_tree_issue"
version = "0.1.0"
edition = "2021"

[dependencies]
patricia_tree = "0.5.0"
# cargo --version
cargo 1.68.0-nightly (2381cbdb4 2022-12-23)
// src/main.rs
use patricia_tree::PatriciaMap;

fn main() {
    let mut map = PatriciaMap::new();
    map.insert("1", 0);
    map.insert("2", 0);
    map.remove("2");
    map.insert("2", 0);

    assert_eq!(map.len(), map.iter().count());
}

... produces the following output.

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `2`,
 right: `1`', src/main.rs:10:5
stack backtrace:
   0: rust_begin_unwind
             at /rustc/270c94e484e19764a2832ef918c95224eb3f17c7/library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at /rustc/270c94e484e19764a2832ef918c95224eb3f17c7/library/core/src/panicking.rs:64:14
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed
             at /rustc/270c94e484e19764a2832ef918c95224eb3f17c7/library/core/src/panicking.rs:201:5
   4: patricia_tree_issue::main
             at ./src/main.rs:10:5
   5: core::ops::function::FnOnce::call_once
             at /rustc/270c94e484e19764a2832ef918c95224eb3f17c7/library/core/src/ops/function.rs:507:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

You would expect the iterator length to match with the map's length. The iter_mut method has the same problem.

@sile
Copy link
Owner

sile commented Jan 23, 2023

Thank you for reporting this bug.
I fixed this bug in #22.

@sile
Copy link
Owner

sile commented Jan 23, 2023

[FYI]
I published a newer version containing the fix. However $ cargo publish aborted during the execution due to timeout, so it seems that the published version is in somewhat inconsistent state. While the latest version is shown on the crates.io page, I could not specify a newer patricia_tree version than 0.5.0 in Cargo.toml.
I will retry tomorrow.

@jean-airoldie
Copy link
Author

Is this the issue you're talking about?

@jean-airoldie
Copy link
Author

@sile
Copy link
Owner

sile commented Jan 23, 2023

Thanks. I succeeded to publish v0.5.5.

@jean-airoldie
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants