Skip to content

Commit c86633d

Browse files
committed
Generalize OrderedSet::contains method
1 parent 762f041 commit c86633d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

syntax/set.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::borrow::Borrow;
12
use std::collections::HashSet;
23
use std::fmt::{self, Debug};
34
use std::hash::Hash;
@@ -27,7 +28,11 @@ where
2728
new
2829
}
2930

30-
pub fn contains(&self, value: &T) -> bool {
31+
pub fn contains<Q>(&self, value: &Q) -> bool
32+
where
33+
&'a T: Borrow<Q>,
34+
Q: ?Sized + Hash + Eq,
35+
{
3136
self.set.contains(value)
3237
}
3338
}

0 commit comments

Comments
 (0)