HashSet::contains has the following type to allow e.g. searching in a HashSet<String> with an &str:
pub fn contains<Q: ?Sized>(&self, value: &Q) -> bool where
T: Borrow<Q>,
Q: Hash + Eq,
However, slice::contains does not use Borrow, so to search in an &[String] one has to actually allocate a String:
pub fn contains(&self, x: &T) -> bool where
T: PartialEq<T>,
Is there a fundamental reason for this, or is this just an omission?
HashSet::containshas the following type to allow e.g. searching in aHashSet<String>with an&str:However,
slice::containsdoes not useBorrow, so to search in an&[String]one has to actually allocate aString:Is there a fundamental reason for this, or is this just an omission?