Skip to content

Commit

Permalink
Add ?Sized
Browse files Browse the repository at this point in the history
  • Loading branch information
varkor committed Dec 23, 2017
1 parent 4138501 commit 6ea22ad
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/liballoc/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ impl<T> [T] {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn contains<U>(&self, x: &U) -> bool
where T: PartialEq<U>
where U: ?Sized, T: PartialEq<U>
{
core_slice::SliceExt::contains(self, x)
}
Expand Down
1 change: 1 addition & 0 deletions src/liballoc/tests/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,7 @@ fn test_contains() {
assert!(!strings.contains(&String::from("A")));
assert!(strings.contains(&"AB"));
assert!(!strings.contains(&"BC"));
assert!(strings.contains("AB"));
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ pub trait SliceExt {
fn as_mut_ptr(&mut self) -> *mut Self::Item;

#[stable(feature = "core", since = "1.6.0")]
fn contains<U>(&self, x: &U) -> bool where Self::Item: PartialEq<U>;
fn contains<U>(&self, x: &U) -> bool where U: ?Sized, Self::Item: PartialEq<U>;

#[stable(feature = "core", since = "1.6.0")]
fn starts_with(&self, needle: &[Self::Item]) -> bool where Self::Item: PartialEq;
Expand Down Expand Up @@ -618,7 +618,7 @@ impl<T> SliceExt for [T] {
}

#[inline]
fn contains<U>(&self, x: &U) -> bool where T: PartialEq<U> {
fn contains<U>(&self, x: &U) -> bool where U: ?Sized, T: PartialEq<U> {
self.iter().any(|e| e == x)
}

Expand Down

0 comments on commit 6ea22ad

Please sign in to comment.