File tree Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,10 @@ pub use crate::recompose::Recompositions;
62
62
pub use crate :: replace:: Replacements ;
63
63
pub use crate :: stream_safe:: StreamSafe ;
64
64
pub use crate :: tables:: UNICODE_VERSION ;
65
- use core:: str:: Chars ;
65
+ use core:: {
66
+ str:: Chars ,
67
+ option,
68
+ } ;
66
69
67
70
mod no_std_prelude;
68
71
@@ -166,6 +169,39 @@ impl<'a> UnicodeNormalization<Chars<'a>> for &'a str {
166
169
}
167
170
}
168
171
172
+
173
+ impl UnicodeNormalization < option:: IntoIter < char > > for char {
174
+ #[ inline]
175
+ fn nfd ( self ) -> Decompositions < option:: IntoIter < char > > {
176
+ decompose:: new_canonical ( Some ( self ) . into_iter ( ) )
177
+ }
178
+
179
+ #[ inline]
180
+ fn nfkd ( self ) -> Decompositions < option:: IntoIter < char > > {
181
+ decompose:: new_compatible ( Some ( self ) . into_iter ( ) )
182
+ }
183
+
184
+ #[ inline]
185
+ fn nfc ( self ) -> Recompositions < option:: IntoIter < char > > {
186
+ recompose:: new_canonical ( Some ( self ) . into_iter ( ) )
187
+ }
188
+
189
+ #[ inline]
190
+ fn nfkc ( self ) -> Recompositions < option:: IntoIter < char > > {
191
+ recompose:: new_compatible ( Some ( self ) . into_iter ( ) )
192
+ }
193
+
194
+ #[ inline]
195
+ fn cjk_compat_variants ( self ) -> Replacements < option:: IntoIter < char > > {
196
+ replace:: new_cjk_compat_variants ( Some ( self ) . into_iter ( ) )
197
+ }
198
+
199
+ #[ inline]
200
+ fn stream_safe ( self ) -> StreamSafe < option:: IntoIter < char > > {
201
+ StreamSafe :: new ( Some ( self ) . into_iter ( ) )
202
+ }
203
+ }
204
+
169
205
impl < I : Iterator < Item = char > > UnicodeNormalization < I > for I {
170
206
#[ inline]
171
207
fn nfd ( self ) -> Decompositions < I > {
Original file line number Diff line number Diff line change @@ -105,6 +105,11 @@ fn test_nfkc() {
105
105
) ;
106
106
}
107
107
108
+ #[ test]
109
+ fn test_normalize_char ( ) {
110
+ assert_eq ! ( '\u{2126}' . nfd( ) . to_string( ) , "\u{3a9} " )
111
+ }
112
+
108
113
#[ test]
109
114
fn test_is_combining_mark_ascii ( ) {
110
115
for cp in 0 ..0x7f {
You can’t perform that action at this time.
0 commit comments