-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from luxbe/master
Implement clone derive for trivial_bounds feature
- Loading branch information
Showing
11 changed files
with
148 additions
and
22 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
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,38 @@ | ||
#![cfg_attr(feature = "trivial_bounds", feature(trivial_bounds))] | ||
#![cfg(feature = "trivial_bounds")] | ||
use multi_index_map::MultiIndexMap; | ||
|
||
#[derive(Hash, PartialEq, Eq, Clone, Debug)] | ||
struct TestNonPrimitiveType(u64); | ||
|
||
#[derive(MultiIndexMap, Clone, Debug)] | ||
struct TestElement { | ||
#[multi_index(hashed_unique)] | ||
field1: TestNonPrimitiveType, | ||
field2: String, | ||
} | ||
|
||
#[test] | ||
fn should_compile() { | ||
let mut map = MultiIndexTestElementMap::default(); | ||
|
||
// check that formatting produces non empty strings | ||
assert!(!format!("{:?}", map._field1_index).is_empty()); | ||
assert!(!format!("{:?}", map._store).is_empty()); | ||
assert!(!format!("{:?}", map).is_empty()); | ||
|
||
let elem1 = TestElement { | ||
field1: TestNonPrimitiveType(42), | ||
field2: "ElementOne".to_string(), | ||
}; | ||
map.insert(elem1); | ||
|
||
let mut new_map = map.clone(); | ||
|
||
assert_eq!(new_map.len(), 1); | ||
|
||
let elem1 = new_map.remove_by_field1(&TestNonPrimitiveType(42)).unwrap(); | ||
assert_eq!(elem1.field1.0, 42); | ||
assert_eq!(elem1.field2, "ElementOne"); | ||
assert_eq!(new_map.len(), 0); | ||
} |
File renamed without changes.
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
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
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
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