-
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 #42 from lun3x/trivial_bounds
Add trivial_bounds feature to enable Debug impl
- Loading branch information
Showing
9 changed files
with
149 additions
and
17 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,33 @@ | ||
#![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 msg = format!("{:?}", map); | ||
// check if stored field 1 is present in debug output | ||
assert!(msg.contains("42")); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,6 @@ convert_case = { version = "0.6" } | |
|
||
[lib] | ||
proc-macro = true | ||
|
||
[features] | ||
trivial_bounds = [] |
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