File tree 3 files changed +4
-3
lines changed
3 files changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -981,7 +981,7 @@ impl<T> [T] {
981
981
/// ```
982
982
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
983
983
pub fn contains < U > ( & self , x : & U ) -> bool
984
- where T : PartialEq < U >
984
+ where U : ? Sized , T : PartialEq < U >
985
985
{
986
986
core_slice:: SliceExt :: contains ( self , x)
987
987
}
Original file line number Diff line number Diff line change @@ -1062,6 +1062,7 @@ fn test_contains() {
1062
1062
assert ! ( !strings. contains( & String :: from( "A" ) ) ) ;
1063
1063
assert ! ( strings. contains( & "AB" ) ) ;
1064
1064
assert ! ( !strings. contains( & "BC" ) ) ;
1065
+ assert ! ( strings. contains( "AB" ) ) ;
1065
1066
}
1066
1067
1067
1068
#[ test]
Original file line number Diff line number Diff line change @@ -192,7 +192,7 @@ pub trait SliceExt {
192
192
fn as_mut_ptr ( & mut self ) -> * mut Self :: Item ;
193
193
194
194
#[ stable( feature = "core" , since = "1.6.0" ) ]
195
- fn contains < U > ( & self , x : & U ) -> bool where Self :: Item : PartialEq < U > ;
195
+ fn contains < U > ( & self , x : & U ) -> bool where U : ? Sized , Self :: Item : PartialEq < U > ;
196
196
197
197
#[ stable( feature = "core" , since = "1.6.0" ) ]
198
198
fn starts_with ( & self , needle : & [ Self :: Item ] ) -> bool where Self :: Item : PartialEq ;
@@ -618,7 +618,7 @@ impl<T> SliceExt for [T] {
618
618
}
619
619
620
620
#[ inline]
621
- fn contains < U > ( & self , x : & U ) -> bool where T : PartialEq < U > {
621
+ fn contains < U > ( & self , x : & U ) -> bool where U : ? Sized , T : PartialEq < U > {
622
622
self . iter ( ) . any ( |e| e == x)
623
623
}
624
624
You can’t perform that action at this time.
0 commit comments