@@ -33,31 +33,25 @@ pub struct Decompositions<I> {
33
33
// to sort in canonical order and is not safe to emit.
34
34
buffer : SmallVec < [ ( u8 , char ) ; 4 ] > ,
35
35
ready : Range < usize > ,
36
-
37
- // The only purpose of this field is to prevent us calling `next` on an
38
- // exhausted iterator; otherwise it would be redundant.
39
- done : bool ,
40
36
}
41
37
42
38
#[ inline]
43
- pub fn new_canonical < I : Iterator < Item = char > > ( iter : I ) -> Decompositions < I > {
39
+ pub fn new_canonical < I : Iterator < Item = char > > ( iter : I ) -> Decompositions < I > {
44
40
Decompositions {
45
41
kind : self :: DecompositionType :: Canonical ,
46
42
iter : iter,
47
43
buffer : SmallVec :: new ( ) ,
48
44
ready : 0 ..0 ,
49
- done : false ,
50
45
}
51
46
}
52
47
53
48
#[ inline]
54
- pub fn new_compatible < I : Iterator < Item = char > > ( iter : I ) -> Decompositions < I > {
49
+ pub fn new_compatible < I : Iterator < Item = char > > ( iter : I ) -> Decompositions < I > {
55
50
Decompositions {
56
51
kind : self :: DecompositionType :: Compatible ,
57
52
iter : iter,
58
53
buffer : SmallVec :: new ( ) ,
59
54
ready : 0 ..0 ,
60
- done : false ,
61
55
}
62
56
}
63
57
@@ -104,14 +98,13 @@ impl<I> Decompositions<I> {
104
98
}
105
99
}
106
100
107
- impl < I : Iterator < Item = char > > Iterator for Decompositions < I > {
101
+ impl < I : Iterator < Item = char > > Iterator for Decompositions < I > {
108
102
type Item = char ;
109
103
110
104
#[ inline]
111
105
fn next ( & mut self ) -> Option < char > {
112
106
while self . ready . end == 0 {
113
- let next = if self . done { None } else { self . iter . next ( ) } ;
114
- match ( next, & self . kind ) {
107
+ match ( self . iter . next ( ) , & self . kind ) {
115
108
( Some ( ch) , & DecompositionType :: Canonical ) => {
116
109
super :: char:: decompose_canonical ( ch, |d| self . push_back ( d) ) ;
117
110
}
@@ -123,7 +116,6 @@ impl<I: Iterator<Item = char>> Iterator for Decompositions<I> {
123
116
return None ;
124
117
} else {
125
118
self . sort_pending ( ) ;
126
- self . done = true ;
127
119
break ;
128
120
}
129
121
}
@@ -141,7 +133,7 @@ impl<I: Iterator<Item = char>> Iterator for Decompositions<I> {
141
133
}
142
134
}
143
135
144
- impl < I : Iterator < Item = char > + Clone > fmt:: Display for Decompositions < I > {
136
+ impl < I : Iterator < Item = char > + Clone > fmt:: Display for Decompositions < I > {
145
137
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
146
138
for c in self . clone ( ) {
147
139
f. write_char ( c) ?;
0 commit comments