Skip to content

Commit

Permalink
Support generic boundaries for Hash derives
Browse files Browse the repository at this point in the history
  • Loading branch information
greyblake committed Jun 9, 2024
1 parent 5c6e13f commit 2e93ee5
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions test_suite/tests/any.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use nutype::nutype;
use std::borrow::Cow;
use std::cmp::{Ordering, PartialEq, PartialOrd};
use std::collections::HashMap;
use std::collections::{HashMap, HashSet};
use std::fmt::{Debug, Display};
use std::hash::Hash;
use test_suite::test_helpers::traits::*;
Expand Down Expand Up @@ -622,7 +622,19 @@ mod with_generics {

#[test]
fn test_generic_boundaries_hash() {
// TODO
#[nutype(derive(PartialEq, Eq, Hash))]
struct WrapperHash<T: PartialEq + Eq + Hash>(T);

#[derive(Hash, PartialEq, Eq)]
struct Number(i32);

let mut set = HashSet::new();
set.insert(WrapperHash::new(Number(1)));
set.insert(WrapperHash::new(Number(1)));
set.insert(WrapperHash::new(Number(2)));

// 1 is inserted twice, so the set should have only two elements
assert_eq!(set.len(), 2);
}

#[test]
Expand Down

0 comments on commit 2e93ee5

Please sign in to comment.