@@ -91,7 +91,7 @@ impl Range {
9191 Ok ( Self :: merge ( ranges) )
9292 }
9393
94- /// Merge any overlapping ranges
94+ /// Merge any overlapping ranges. Adjacent ranges are *NOT* merged.
9595 ///
9696 /// Is guaranteed to return only disjoint ranges in a sorted order.
9797 fn merge ( mut ranges : Vec < Self > ) -> Vec < Self > {
@@ -101,10 +101,7 @@ impl Range {
101101 for i in 0 ..ranges. len ( ) {
102102 let j = i + 1 ;
103103
104- // The +1 is a small optimization, because we can merge adjacent Ranges.
105- // For example (1,3) and (4,6), because in the integers, there are no
106- // possible values between 3 and 4, this is equivalent to (1,6).
107- while j < ranges. len ( ) && ranges[ j] . low <= ranges[ i] . high + 1 {
104+ while j < ranges. len ( ) && ranges[ j] . low <= ranges[ i] . high {
108105 let j_high = ranges. remove ( j) . high ;
109106 ranges[ i] . high = max ( ranges[ i] . high , j_high) ;
110107 }
@@ -216,8 +213,8 @@ mod test {
216213 & [ r ( 10 , 40 ) , r ( 50 , 60 ) ] ,
217214 ) ;
218215
219- // Merge adjacent ranges
220- m ( vec ! [ r( 1 , 3 ) , r( 4 , 6 ) ] , & [ r ( 1 , 6 ) ] ) ;
216+ // Don't merge adjacent ranges
217+ m ( vec ! [ r( 1 , 3 ) , r( 4 , 6 ) ] , & [ r ( 1 , 3 ) , r ( 4 , 6 ) ] ) ;
221218 }
222219
223220 #[ test]
0 commit comments