@@ -538,13 +538,13 @@ pub struct StrStrSplitIterator<'self> {
538
538
priv finished : bool
539
539
}
540
540
541
- <<<<<<< HEAD
542
541
impl < ' self > Iterator < ( uint , uint ) > for StrMatchesIndexIterator < ' self > {
543
542
#[ inline]
544
543
fn next ( & mut self ) -> Option < ( uint , uint ) > {
545
544
// See Issue #1932 for why this is a naive search
546
545
let ( h_len, n_len) = ( self . haystack . len ( ) , self . needle . len ( ) ) ;
547
- let mut ( match_start , match_i ) = ( 0 , 0 ) ;
546
+ let mut match_start = 0 ;
547
+ let mut match_i = 0 ;
548
548
549
549
while self . position < h_len {
550
550
if self . haystack [ self . position ] == self . needle [ match_i] {
@@ -561,24 +561,6 @@ impl<'self> Iterator<(uint, uint)> for StrMatchesIndexIterator<'self> {
561
561
if match_i > 0 {
562
562
match_i = 0 ;
563
563
self . position = match_start;
564
- =======
565
- fn each_split_inner < ' a > ( s : & ' a str ,
566
- sepfn : & fn ( cc : char ) -> bool ,
567
- count : uint ,
568
- allow_empty : bool ,
569
- allow_trailing_empty : bool ,
570
- it : & fn ( & ' a str ) -> bool ) -> bool {
571
- let l = len ( s) ;
572
- let mut i = 0 u;
573
- let mut start = 0 u;
574
- let mut done = 0 u;
575
- while i < l && done < count {
576
- let CharRange { ch, next} = char_range_at ( s, i) ;
577
- if sepfn ( ch) {
578
- if allow_empty || start < i {
579
- if !it ( unsafe { raw:: slice_bytes ( s, start, i) } ) {
580
- return false ;
581
- >>>>>>> librustc: Disallow "mut" from distributing over bindings.
582
564
}
583
565
self . position += 1 ;
584
566
}
@@ -587,7 +569,6 @@ fn each_split_inner<'a>(s: &'a str,
587
569
}
588
570
}
589
571
590
- <<<<<<< HEAD
591
572
impl < ' self > Iterator < & ' self str > for StrStrSplitIterator < ' self > {
592
573
#[ inline]
593
574
fn next ( & mut self ) -> Option < & ' self str > {
@@ -598,25 +579,6 @@ impl<'self> Iterator<&'self str> for StrStrSplitIterator<'self> {
598
579
let ret = Some ( self . it . haystack . slice ( self . last_end , from) ) ;
599
580
self . last_end = to;
600
581
ret
601
- =======
602
- // See Issue #1932 for why this is a naive search
603
- fn iter_matches < ' a , ' b > ( s : & ' a str , sep : & ' b str ,
604
- f : & fn ( uint , uint ) -> bool ) -> bool {
605
- let ( sep_len , l ) = ( len ( sep ) , len ( s ) ) ;
606
- assert ! ( sep_len > 0 u) ;
607
- let mut i = 0 u ;
608
- let mut match_start = 0 u ;
609
- let mut match_i = 0 u ;
610
-
611
- while i < l {
612
- if s[ i] == sep[ match_i] {
613
- if match_i == 0 u { match_start = i; }
614
- match_i += 1 u;
615
- // Found a match
616
- if match_i == sep_len {
617
- if !f ( match_start, i + 1 u) { return false ; }
618
- match_i = 0 u;
619
- >>>>>>> librustc: Disallow "mut" from distributing over bindings.
620
582
}
621
583
None => {
622
584
self . finished = true ;
@@ -762,23 +724,12 @@ pub fn each_split_within<'a>(ss: &'a str,
762
724
* The original string with all occurances of `from` replaced with `to`
763
725
*/
764
726
pub fn replace ( s : & str , from : & str , to : & str ) -> ~str {
765
- <<<<<<< HEAD
766
- let mut ( result , last_end ) = ( ~"" , 0 ) ;
727
+ let mut result = ~"" ;
728
+ let mut last_end = 0 ;
767
729
for s. matches_index_iter( from) . advance |( start, end) | {
768
730
result. push_str ( unsafe { raw:: slice_bytes ( s, last_end, start) } ) ;
769
731
result. push_str ( to) ;
770
732
last_end = end;
771
- =======
772
- let mut result = ~"";
773
- let mut first = true;
774
- for iter_between_matches ( s , from ) |start , end | {
775
- if first {
776
- first = false;
777
- } else {
778
- push_str ( & mut result , to ) ;
779
- }
780
- push_str ( & mut result , unsafe { raw :: slice_bytes ( s , start , end ) } ) ;
781
- >>>>>>> librustc: Disallow "mut " from distributing over bindings.
782
733
}
783
734
result. push_str ( unsafe { raw:: slice_bytes ( s, last_end, s. len ( ) ) } ) ;
784
735
result
@@ -1167,16 +1118,10 @@ pub fn with_capacity(capacity: uint) -> ~str {
1167
1118
* The number of Unicode characters in `s` between the given indices.
1168
1119
*/
1169
1120
pub fn count_chars( s: & str , start : uint , end : uint ) -> uint {
1170
- <<<<<<< HEAD
1171
1121
assert ! ( s. is_char_boundary( start) ) ;
1172
1122
assert ! ( s. is_char_boundary( end) ) ;
1173
- let mut ( i , len ) = ( start , 0 u ) ;
1174
- =======
1175
- assert ! ( is_char_boundary( s, start) ) ;
1176
- assert ! ( is_char_boundary( s, end) ) ;
1177
1123
let mut i = start;
1178
1124
let mut len = 0 u;
1179
- >>>>>>> librustc: Disallow "mut " from distributing over bindings.
1180
1125
while i < end {
1181
1126
let next = s. char_range_at ( i) . next ;
1182
1127
len += 1 u;
@@ -1188,16 +1133,10 @@ pub fn count_chars(s: &str, start: uint, end: uint) -> uint {
1188
1133
/// Counts the number of bytes taken by the first `n` chars in `s`
1189
1134
/// starting from `start`.
1190
1135
pub fn count_bytes < ' b > ( s : & ' b str , start : uint , n : uint ) -> uint {
1191
- <<<<<<< HEAD
1192
1136
assert ! ( s. is_char_boundary( start) ) ;
1193
- let mut ( end , cnt ) = ( start , n ) ;
1194
- let l = s. len ( ) ;
1195
- =======
1196
- assert ! ( is_char_boundary( s, start) ) ;
1197
1137
let mut end = start;
1198
1138
let mut cnt = n;
1199
- let l = len ( s ) ;
1200
- >>>>>>> librustc: Disallow "mut " from distributing over bindings.
1139
+ let l = s. len ( ) ;
1201
1140
while cnt > 0 u {
1202
1141
assert ! ( end < l) ;
1203
1142
let next = s. char_range_at ( end) . next ;
0 commit comments