Skip to content

Commit

Permalink
Fix VersionMap no longer being Send+Sync
Browse files Browse the repository at this point in the history
I overlooked that e00a8b5 was not
part of 0.1.6 and introduced a breaking change, as the `dyn
VersionFilter` field prevented `VersionMap` from being sharable between
threads. As this was previously the case, this meant a breaking change
snuck into a patch release, so 0.1.7 was yanked and instead we need
to release 0.1.8

Signed-off-by: Patrick Roy <[email protected]>
  • Loading branch information
roypat authored and dianpopa committed Nov 22, 2022
1 parent ffd8152 commit 3a7d2bc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "versionize"
version = "0.1.7"
version = "0.1.8"
license = "Apache-2.0"
authors = ["Amazon Firecracker team <[email protected]>"]
description = "A version tolerant serialization/deserialization framework."
Expand Down
11 changes: 9 additions & 2 deletions src/version_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl VersionFilter for () {
#[derive(Clone, Debug)]
pub struct VersionMap {
versions: Vec<HashMap<TypeId, u16>>,
filter: Arc<dyn VersionFilter>,
filter: Arc<dyn VersionFilter + Send + Sync>,
}

impl Default for VersionMap {
Expand All @@ -102,7 +102,7 @@ impl VersionMap {
}

/// Create a new version map with specified version filter.
pub fn with_filter(filter: Arc<dyn VersionFilter>) -> Self {
pub fn with_filter(filter: Arc<dyn VersionFilter + Send + Sync>) -> Self {
VersionMap {
versions: vec![HashMap::new(); 1],
filter,
Expand Down Expand Up @@ -220,6 +220,13 @@ mod tests {
}
}

#[test]
fn test_version_map_is_send_and_sync() {
fn assert_send_sync<T: Send + Sync>() {}

assert_send_sync::<VersionMap>();
}

#[test]
fn test_app_versions_with_gap() {
let my_type_id = TypeId::of::<MyType>();
Expand Down

0 comments on commit 3a7d2bc

Please sign in to comment.