diff --git a/chitchat-test/Cargo.toml b/chitchat-test/Cargo.toml index 1308180..1a1ba11 100644 --- a/chitchat-test/Cargo.toml +++ b/chitchat-test/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "chitchat-test" -version = "0.6.0" +version = "0.7.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -chitchat = { version = "0.6.0", path = "../chitchat" } +chitchat = { version = "0.7.0", path = "../chitchat" } poem = "1" poem-openapi = {version="1.3", features = ["swagger-ui"] } structopt = "0.3" diff --git a/chitchat/Cargo.toml b/chitchat/Cargo.toml index 8169c23..c86751f 100644 --- a/chitchat/Cargo.toml +++ b/chitchat/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "chitchat" -version = "0.6.0" +version = "0.7.0" edition = "2021" license = "MIT" authors = ["Quickwit, Inc. "] diff --git a/chitchat/src/state.rs b/chitchat/src/state.rs index 1153881..c0c5ffd 100644 --- a/chitchat/src/state.rs +++ b/chitchat/src/state.rs @@ -89,9 +89,9 @@ impl NodeState { /// Setting a new value automatically increments the /// version of the entire NodeState regardless of whether the /// value is really changed or not. - pub fn set, V: Into>(&mut self, key: K, value: V) { + pub fn set(&mut self, key: impl ToString, value: impl ToString) { let new_version = self.max_version + 1; - self.set_with_version(key.into(), value.into(), new_version); + self.set_with_version(key.to_string(), value.to_string(), new_version); } /// Marks key for deletion and sets the value to an empty string. diff --git a/chitchat/src/transport/channel.rs b/chitchat/src/transport/channel.rs index 67c5a24..11ba515 100644 --- a/chitchat/src/transport/channel.rs +++ b/chitchat/src/transport/channel.rs @@ -80,15 +80,9 @@ impl ChannelTransport { pub async fn remove_link(&self, from_addr: SocketAddr, to_addr: SocketAddr) { let mut inner_lock = self.inner.lock().unwrap(); - let from_addr_entry = inner_lock - .removed_links - .entry(from_addr) - .or_insert_with(HashSet::new); + let from_addr_entry = inner_lock.removed_links.entry(from_addr).or_default(); from_addr_entry.insert(to_addr); - let to_addr_entry = inner_lock - .removed_links - .entry(to_addr) - .or_insert_with(HashSet::new); + let to_addr_entry = inner_lock.removed_links.entry(to_addr).or_default(); to_addr_entry.insert(from_addr); } diff --git a/chitchat/tests/cluster_test.rs b/chitchat/tests/cluster_test.rs index 30d376f..dccd7ab 100644 --- a/chitchat/tests/cluster_test.rs +++ b/chitchat/tests/cluster_test.rs @@ -480,7 +480,7 @@ async fn test_simple_simulation_heavy_insert_delete() { keys_values.push((key.to_string(), value.to_string())); let keys_entry = keys_values_inserted_per_chitchat_id .entry(chitchat_id.clone()) - .or_insert_with(HashSet::new); + .or_default(); keys_entry.insert(key.to_string()); } simulator