@@ -242,8 +242,10 @@ pub unsafe fn from_c_str(s: *const i8) -> &'static str {
242242}
243243
244244/// Something that can be used to compare against a character
245- #[ unstable( feature = "core" ,
246- reason = "definition may change as pattern-related methods are stabilized" ) ]
245+ #[ unstable( feature = "core" ) ]
246+ #[ deprecated( since = "1.0.0" ,
247+ reason = "use `Pattern` instead" ) ]
248+ // NB: Rather than removing it, make it private and move it into self::pattern
247249pub trait CharEq {
248250 /// Determine if the splitter should split at the given character
249251 fn matches ( & mut self , char ) -> bool ;
@@ -252,6 +254,7 @@ pub trait CharEq {
252254 fn only_ascii ( & self ) -> bool ;
253255}
254256
257+ #[ allow( deprecated) /* for CharEq */ ]
255258impl CharEq for char {
256259 #[ inline]
257260 fn matches ( & mut self , c : char ) -> bool { * self == c }
@@ -260,6 +263,7 @@ impl CharEq for char {
260263 fn only_ascii ( & self ) -> bool { ( * self as u32 ) < 128 }
261264}
262265
266+ #[ allow( deprecated) /* for CharEq */ ]
263267impl < F > CharEq for F where F : FnMut ( char ) -> bool {
264268 #[ inline]
265269 fn matches ( & mut self , c : char ) -> bool { ( * self ) ( c) }
@@ -268,13 +272,16 @@ impl<F> CharEq for F where F: FnMut(char) -> bool {
268272 fn only_ascii ( & self ) -> bool { false }
269273}
270274
275+ #[ allow( deprecated) /* for CharEq */ ]
271276impl < ' a > CharEq for & ' a [ char ] {
272277 #[ inline]
278+ #[ allow( deprecated) /* for CharEq */ ]
273279 fn matches ( & mut self , c : char ) -> bool {
274280 self . iter ( ) . any ( |& m| { let mut m = m; m. matches ( c) } )
275281 }
276282
277283 #[ inline]
284+ #[ allow( deprecated) /* for CharEq */ ]
278285 fn only_ascii ( & self ) -> bool {
279286 self . iter ( ) . all ( |m| m. only_ascii ( ) )
280287 }
@@ -764,7 +771,7 @@ impl TwoWaySearcher {
764771 // that (u, v) is a critical factorization for the needle.
765772 #[ inline]
766773 fn next ( & mut self , haystack : & [ u8 ] , needle : & [ u8 ] , long_period : bool )
767- -> Option < ( usize , usize ) > {
774+ -> Option < ( usize , usize ) > {
768775 ' search: loop {
769776 // Check that we have room to search in
770777 if self . position + needle. len ( ) > haystack. len ( ) {
@@ -866,6 +873,8 @@ impl TwoWaySearcher {
866873/// The internal state of an iterator that searches for matches of a substring
867874/// within a larger string using a dynamically chosen search algorithm
868875#[ derive( Clone ) ]
876+ // NB: This is kept around for convenience because
877+ // it is planned to be used again in the future
869878enum OldSearcher {
870879 TwoWay ( TwoWaySearcher ) ,
871880 TwoWayLong ( TwoWaySearcher ) ,
@@ -896,6 +905,8 @@ impl OldSearcher {
896905}
897906
898907#[ derive( Clone ) ]
908+ // NB: This is kept around for convenience because
909+ // it is planned to be used again in the future
899910struct OldMatchIndices < ' a , ' b > {
900911 // constants
901912 haystack : & ' a str ,
@@ -921,7 +932,8 @@ impl<'a, P: Pattern<'a>> Iterator for MatchIndices<'a, P> {
921932
922933/// An iterator over the substrings of a string separated by a given
923934/// search string
924- #[ unstable( feature = "core" , reason = "type may be removed" ) ]
935+ #[ unstable( feature = "core" ) ]
936+ #[ deprecated( since = "1.0.0" , reason = "use `Split` with a `&str`" ) ]
925937pub struct SplitStr < ' a , P : Pattern < ' a > > ( Split < ' a , P > ) ;
926938impl < ' a , P : Pattern < ' a > > Iterator for SplitStr < ' a , P > {
927939 type Item = & ' a str ;
@@ -1282,8 +1294,7 @@ where P::Searcher: DoubleEndedSearcher<'a> {
12821294}
12831295
12841296/// Return type of `StrExt::split_terminator`
1285- #[ unstable( feature = "core" ,
1286- reason = "might get removed in favour of a constructor method on Split" ) ]
1297+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
12871298pub struct SplitTerminator < ' a , P : Pattern < ' a > > ( CharSplits < ' a , P > ) ;
12881299delegate_iter ! { pattern & ' a str : SplitTerminator <' a, P >}
12891300
@@ -1421,6 +1432,7 @@ impl StrExt for str {
14211432 }
14221433
14231434 #[ inline]
1435+ #[ allow( deprecated) /* for SplitStr */ ]
14241436 fn split_str < ' a , P : Pattern < ' a > > ( & ' a self , pat : P ) -> SplitStr < ' a , P > {
14251437 SplitStr ( self . split ( pat) )
14261438 }
@@ -1477,18 +1489,20 @@ impl StrExt for str {
14771489
14781490 #[ inline]
14791491 fn starts_with < ' a , P : Pattern < ' a > > ( & ' a self , pat : P ) -> bool {
1480- pat. match_starts_at ( self , 0 )
1492+ pat. is_prefix_of ( self )
14811493 }
14821494
14831495 #[ inline]
14841496 fn ends_with < ' a , P : Pattern < ' a > > ( & ' a self , pat : P ) -> bool
1485- where P :: Searcher : ReverseSearcher < ' a > {
1486- pat. match_ends_at ( self , self . len ( ) )
1497+ where P :: Searcher : ReverseSearcher < ' a >
1498+ {
1499+ pat. is_suffix_of ( self )
14871500 }
14881501
14891502 #[ inline]
14901503 fn trim_matches < ' a , P : Pattern < ' a > > ( & ' a self , pat : P ) -> & ' a str
1491- where P :: Searcher : DoubleEndedSearcher < ' a > {
1504+ where P :: Searcher : DoubleEndedSearcher < ' a >
1505+ {
14921506 let mut i = 0 ;
14931507 let mut j = 0 ;
14941508 let mut matcher = pat. into_searcher ( self ) ;
@@ -1521,7 +1535,8 @@ impl StrExt for str {
15211535
15221536 #[ inline]
15231537 fn trim_right_matches < ' a , P : Pattern < ' a > > ( & ' a self , pat : P ) -> & ' a str
1524- where P :: Searcher : ReverseSearcher < ' a > {
1538+ where P :: Searcher : ReverseSearcher < ' a >
1539+ {
15251540 let mut j = 0 ;
15261541 let mut matcher = pat. into_searcher ( self ) ;
15271542 if let Some ( ( _, b) ) = matcher. next_reject_back ( ) {
@@ -1599,7 +1614,8 @@ impl StrExt for str {
15991614 }
16001615
16011616 fn rfind < ' a , P : Pattern < ' a > > ( & ' a self , pat : P ) -> Option < usize >
1602- where P :: Searcher : ReverseSearcher < ' a > {
1617+ where P :: Searcher : ReverseSearcher < ' a >
1618+ {
16031619 pat. into_searcher ( self ) . next_match_back ( ) . map ( |( i, _) | i)
16041620 }
16051621
0 commit comments