billyrieger / bimap-rs

Generic bijective maps in Rust
Apache License 2.0
129 stars 26 forks source link

Adding must_use to Overwritten Seems Beneficial #42

Open higumachan opened 1 year ago

higumachan commented 1 year ago

Thank you very much for this outstanding crate.

While utilizing this crate, I have encountered the following issue related to an implicit Overwritten behavior.

let mut bimap = BiBTreeMap::new();
bimap.insert('a', 2);
bimap.insert('b', 2);

assert_eq!(bimap.len() == 1);  // but I expected bimap.len() == 2

I understand that due to the characteristics of bimap, this behavior is unavoidable and is clearly documented. In my case, I've found that using insert_no_overwrite is the better approach and I'm currently doing so.

However, I'm suggesting that by adding #[must_use] to Overwritten, we could make the resolution more explicit.

I've created a draft PR(#41) and would appreciate any feedback on this matter.