-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement extend for StringMap (#257)
Signed-off-by: Xudong Sun <[email protected]>
- Loading branch information
1 parent
c1b68a8
commit 1e016bc
Showing
6 changed files
with
44 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Copyright 2022 VMware, Inc. | ||
// SPDX-License-Identifier: MIT | ||
pub mod object_meta; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright 2022 VMware, Inc. | ||
// SPDX-License-Identifier: MIT | ||
pub mod object_meta; | ||
|
||
pub mod kubernetes_api_objects; | ||
pub mod vstd_ext; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Copyright 2022 VMware, Inc. | ||
// SPDX-License-Identifier: MIT | ||
pub mod string_map; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2022 VMware, Inc. | ||
// SPDX-License-Identifier: MIT | ||
use crate::pervasive_ext::string_map::*; | ||
use vstd::prelude::*; | ||
use vstd::string::*; | ||
|
||
verus! { | ||
|
||
#[test] | ||
#[verifier(external)] | ||
pub fn test_extend() { | ||
let mut m = StringMap::empty(); | ||
m.insert(new_strlit("key1").to_string(), new_strlit("val1").to_string()); | ||
m.insert(new_strlit("key2").to_string(), new_strlit("val2").to_string()); | ||
|
||
let mut m2 = StringMap::empty(); | ||
m.insert(new_strlit("key1").to_string(), new_strlit("new_val1").to_string()); | ||
m.insert(new_strlit("key3").to_string(), new_strlit("val3").to_string()); | ||
|
||
m.extend(m2); | ||
|
||
let rust_map = m.into_rust_map(); | ||
assert_eq!(rust_map.get(&"key1".to_string()), Some(&"new_val1".to_string())); | ||
assert_eq!(rust_map.get(&"key2".to_string()), Some(&"val2".to_string())); | ||
assert_eq!(rust_map.get(&"key3".to_string()), Some(&"val3".to_string())); | ||
} | ||
|
||
} |