@@ -242,8 +242,10 @@ pub unsafe fn from_c_str(s: *const i8) -> &'static str {
242
242
}
243
243
244
244
/// 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
247
249
pub trait CharEq {
248
250
/// Determine if the splitter should split at the given character
249
251
fn matches ( & mut self , char ) -> bool ;
@@ -252,6 +254,7 @@ pub trait CharEq {
252
254
fn only_ascii ( & self ) -> bool ;
253
255
}
254
256
257
+ #[ allow( deprecated) /* for CharEq */ ]
255
258
impl CharEq for char {
256
259
#[ inline]
257
260
fn matches ( & mut self , c : char ) -> bool { * self == c }
@@ -260,6 +263,7 @@ impl CharEq for char {
260
263
fn only_ascii ( & self ) -> bool { ( * self as u32 ) < 128 }
261
264
}
262
265
266
+ #[ allow( deprecated) /* for CharEq */ ]
263
267
impl < F > CharEq for F where F : FnMut ( char ) -> bool {
264
268
#[ inline]
265
269
fn matches ( & mut self , c : char ) -> bool { ( * self ) ( c) }
@@ -268,13 +272,16 @@ impl<F> CharEq for F where F: FnMut(char) -> bool {
268
272
fn only_ascii ( & self ) -> bool { false }
269
273
}
270
274
275
+ #[ allow( deprecated) /* for CharEq */ ]
271
276
impl < ' a > CharEq for & ' a [ char ] {
272
277
#[ inline]
278
+ #[ allow( deprecated) /* for CharEq */ ]
273
279
fn matches ( & mut self , c : char ) -> bool {
274
280
self . iter ( ) . any ( |& m| { let mut m = m; m. matches ( c) } )
275
281
}
276
282
277
283
#[ inline]
284
+ #[ allow( deprecated) /* for CharEq */ ]
278
285
fn only_ascii ( & self ) -> bool {
279
286
self . iter ( ) . all ( |m| m. only_ascii ( ) )
280
287
}
@@ -764,7 +771,7 @@ impl TwoWaySearcher {
764
771
// that (u, v) is a critical factorization for the needle.
765
772
#[ inline]
766
773
fn next ( & mut self , haystack : & [ u8 ] , needle : & [ u8 ] , long_period : bool )
767
- -> Option < ( usize , usize ) > {
774
+ -> Option < ( usize , usize ) > {
768
775
' search: loop {
769
776
// Check that we have room to search in
770
777
if self . position + needle. len ( ) > haystack. len ( ) {
@@ -866,6 +873,8 @@ impl TwoWaySearcher {
866
873
/// The internal state of an iterator that searches for matches of a substring
867
874
/// within a larger string using a dynamically chosen search algorithm
868
875
#[ derive( Clone ) ]
876
+ // NB: This is kept around for convenience because
877
+ // it is planned to be used again in the future
869
878
enum OldSearcher {
870
879
TwoWay ( TwoWaySearcher ) ,
871
880
TwoWayLong ( TwoWaySearcher ) ,
@@ -896,6 +905,8 @@ impl OldSearcher {
896
905
}
897
906
898
907
#[ derive( Clone ) ]
908
+ // NB: This is kept around for convenience because
909
+ // it is planned to be used again in the future
899
910
struct OldMatchIndices < ' a , ' b > {
900
911
// constants
901
912
haystack : & ' a str ,
@@ -921,7 +932,8 @@ impl<'a, P: Pattern<'a>> Iterator for MatchIndices<'a, P> {
921
932
922
933
/// An iterator over the substrings of a string separated by a given
923
934
/// 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`" ) ]
925
937
pub struct SplitStr < ' a , P : Pattern < ' a > > ( Split < ' a , P > ) ;
926
938
impl < ' a , P : Pattern < ' a > > Iterator for SplitStr < ' a , P > {
927
939
type Item = & ' a str ;
@@ -1282,8 +1294,7 @@ where P::Searcher: DoubleEndedSearcher<'a> {
1282
1294
}
1283
1295
1284
1296
/// 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" ) ]
1287
1298
pub struct SplitTerminator < ' a , P : Pattern < ' a > > ( CharSplits < ' a , P > ) ;
1288
1299
delegate_iter ! { pattern & ' a str : SplitTerminator <' a, P >}
1289
1300
@@ -1421,6 +1432,7 @@ impl StrExt for str {
1421
1432
}
1422
1433
1423
1434
#[ inline]
1435
+ #[ allow( deprecated) /* for SplitStr */ ]
1424
1436
fn split_str < ' a , P : Pattern < ' a > > ( & ' a self , pat : P ) -> SplitStr < ' a , P > {
1425
1437
SplitStr ( self . split ( pat) )
1426
1438
}
@@ -1477,18 +1489,20 @@ impl StrExt for str {
1477
1489
1478
1490
#[ inline]
1479
1491
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 )
1481
1493
}
1482
1494
1483
1495
#[ inline]
1484
1496
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 )
1487
1500
}
1488
1501
1489
1502
#[ inline]
1490
1503
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
+ {
1492
1506
let mut i = 0 ;
1493
1507
let mut j = 0 ;
1494
1508
let mut matcher = pat. into_searcher ( self ) ;
@@ -1521,7 +1535,8 @@ impl StrExt for str {
1521
1535
1522
1536
#[ inline]
1523
1537
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
+ {
1525
1540
let mut j = 0 ;
1526
1541
let mut matcher = pat. into_searcher ( self ) ;
1527
1542
if let Some ( ( _, b) ) = matcher. next_reject_back ( ) {
@@ -1599,7 +1614,8 @@ impl StrExt for str {
1599
1614
}
1600
1615
1601
1616
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
+ {
1603
1619
pat. into_searcher ( self ) . next_match_back ( ) . map ( |( i, _) | i)
1604
1620
}
1605
1621
0 commit comments