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 9
9
// except according to those terms.
10
10
use smallvec:: SmallVec ;
11
11
use std:: fmt:: { self , Write } ;
12
+ use std:: iter:: Fuse ;
12
13
use std:: ops:: Range ;
13
14
14
15
#[ derive( Clone ) ]
@@ -21,7 +22,7 @@ enum DecompositionType {
21
22
#[ derive( Clone ) ]
22
23
pub struct Decompositions < I > {
23
24
kind : DecompositionType ,
24
- iter : I ,
25
+ iter : Fuse < I > ,
25
26
26
27
// This buffer stores pairs of (canonical combining class, character),
27
28
// pushed onto the end in text order.
@@ -39,7 +40,7 @@ pub struct Decompositions<I> {
39
40
pub fn new_canonical < I : Iterator < Item =char > > ( iter : I ) -> Decompositions < I > {
40
41
Decompositions {
41
42
kind : self :: DecompositionType :: Canonical ,
42
- iter : iter,
43
+ iter : iter. fuse ( ) ,
43
44
buffer : SmallVec :: new ( ) ,
44
45
ready : 0 ..0 ,
45
46
}
@@ -49,7 +50,7 @@ pub fn new_canonical<I: Iterator<Item=char>>(iter: I) -> Decompositions<I> {
49
50
pub fn new_compatible < I : Iterator < Item =char > > ( iter : I ) -> Decompositions < I > {
50
51
Decompositions {
51
52
kind : self :: DecompositionType :: Compatible ,
52
- iter : iter,
53
+ iter : iter. fuse ( ) ,
53
54
buffer : SmallVec :: new ( ) ,
54
55
ready : 0 ..0 ,
55
56
}
@@ -116,6 +117,11 @@ impl<I: Iterator<Item=char>> Iterator for Decompositions<I> {
116
117
return None ;
117
118
} else {
118
119
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`.
119
125
break ;
120
126
}
121
127
}
You can’t perform that action at this time.
0 commit comments