File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 99// except according to those terms.
1010use smallvec:: SmallVec ;
1111use std:: fmt:: { self , Write } ;
12+ use std:: iter:: Fuse ;
1213use std:: ops:: Range ;
1314
1415#[ derive( Clone ) ]
@@ -21,7 +22,7 @@ enum DecompositionType {
2122#[ derive( Clone ) ]
2223pub struct Decompositions < I > {
2324 kind : DecompositionType ,
24- iter : I ,
25+ iter : Fuse < I > ,
2526
2627 // This buffer stores pairs of (canonical combining class, character),
2728 // pushed onto the end in text order.
@@ -39,7 +40,7 @@ pub struct Decompositions<I> {
3940pub fn new_canonical < I : Iterator < Item =char > > ( iter : I ) -> Decompositions < I > {
4041 Decompositions {
4142 kind : self :: DecompositionType :: Canonical ,
42- iter : iter,
43+ iter : iter. fuse ( ) ,
4344 buffer : SmallVec :: new ( ) ,
4445 ready : 0 ..0 ,
4546 }
@@ -49,7 +50,7 @@ pub fn new_canonical<I: Iterator<Item=char>>(iter: I) -> Decompositions<I> {
4950pub fn new_compatible < I : Iterator < Item =char > > ( iter : I ) -> Decompositions < I > {
5051 Decompositions {
5152 kind : self :: DecompositionType :: Compatible ,
52- iter : iter,
53+ iter : iter. fuse ( ) ,
5354 buffer : SmallVec :: new ( ) ,
5455 ready : 0 ..0 ,
5556 }
@@ -116,6 +117,11 @@ impl<I: Iterator<Item=char>> Iterator for Decompositions<I> {
116117 return None ;
117118 } else {
118119 self . sort_pending ( ) ;
120+
121+ // This implementation means that we can call `next`
122+ // on an exhausted iterator; the last outer `next` call
123+ // will result in an inner `next` call. To make this
124+ // safe, we use `fuse`.
119125 break ;
120126 }
121127 }
You can’t perform that action at this time.
0 commit comments