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;
6262pub use crate :: replace:: Replacements ;
6363pub use crate :: stream_safe:: StreamSafe ;
6464pub use crate :: tables:: UNICODE_VERSION ;
65- use core:: str:: Chars ;
65+ use core:: {
66+ str:: Chars ,
67+ option,
68+ } ;
6669
6770mod no_std_prelude;
6871
@@ -166,6 +169,39 @@ impl<'a> UnicodeNormalization<Chars<'a>> for &'a str {
166169 }
167170}
168171
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+
169205impl < I : Iterator < Item = char > > UnicodeNormalization < I > for I {
170206 #[ inline]
171207 fn nfd ( self ) -> Decompositions < I > {
Original file line number Diff line number Diff line change @@ -105,6 +105,11 @@ fn test_nfkc() {
105105 ) ;
106106}
107107
108+ #[ test]
109+ fn test_normalize_char ( ) {
110+ assert_eq ! ( '\u{2126}' . nfd( ) . to_string( ) , "\u{3a9} " )
111+ }
112+
108113#[ test]
109114fn test_is_combining_mark_ascii ( ) {
110115 for cp in 0 ..0x7f {
You can’t perform that action at this time.
0 commit comments