|
38 | 38 | //! ``` |
39 | 39 |
|
40 | 40 | #![deny(missing_docs, unsafe_code)] |
41 | | -#![doc(html_logo_url = "https://unicode-rs.github.io/unicode-rs_sm.png", |
42 | | - html_favicon_url = "https://unicode-rs.github.io/unicode-rs_sm.png")] |
| 41 | +#![doc( |
| 42 | + html_logo_url = "https://unicode-rs.github.io/unicode-rs_sm.png", |
| 43 | + html_favicon_url = "https://unicode-rs.github.io/unicode-rs_sm.png" |
| 44 | +)] |
| 45 | +#![cfg_attr(not(feature = "std"), no_std)] |
| 46 | + |
| 47 | +#[cfg(not(feature = "std"))] |
| 48 | +extern crate alloc; |
| 49 | + |
| 50 | +#[cfg(feature = "std")] |
| 51 | +extern crate core; |
43 | 52 |
|
44 | 53 | extern crate tinyvec; |
45 | 54 |
|
46 | | -pub use tables::UNICODE_VERSION; |
47 | | -pub use decompose::Decompositions; |
48 | | -pub use quick_check::{ |
| 55 | +pub use crate::decompose::Decompositions; |
| 56 | +pub use crate::quick_check::{ |
| 57 | + is_nfc, is_nfc_quick, is_nfc_stream_safe, is_nfc_stream_safe_quick, is_nfd, is_nfd_quick, |
| 58 | + is_nfd_stream_safe, is_nfd_stream_safe_quick, is_nfkc, is_nfkc_quick, is_nfkd, is_nfkd_quick, |
49 | 59 | IsNormalized, |
50 | | - is_nfc, |
51 | | - is_nfc_quick, |
52 | | - is_nfkc, |
53 | | - is_nfkc_quick, |
54 | | - is_nfc_stream_safe, |
55 | | - is_nfc_stream_safe_quick, |
56 | | - is_nfd, |
57 | | - is_nfd_quick, |
58 | | - is_nfkd, |
59 | | - is_nfkd_quick, |
60 | | - is_nfd_stream_safe, |
61 | | - is_nfd_stream_safe_quick, |
62 | 60 | }; |
63 | | -pub use recompose::Recompositions; |
64 | | -pub use stream_safe::StreamSafe; |
65 | | -use std::str::Chars; |
| 61 | +pub use crate::recompose::Recompositions; |
| 62 | +pub use crate::stream_safe::StreamSafe; |
| 63 | +pub use crate::tables::UNICODE_VERSION; |
| 64 | +use core::str::Chars; |
| 65 | + |
| 66 | +mod no_std_prelude; |
66 | 67 |
|
67 | 68 | mod decompose; |
68 | 69 | mod lookups; |
69 | 70 | mod normalize; |
70 | 71 | mod perfect_hash; |
71 | | -mod recompose; |
72 | 72 | mod quick_check; |
| 73 | +mod recompose; |
73 | 74 | mod stream_safe; |
| 75 | + |
| 76 | +#[rustfmt::skip] |
74 | 77 | mod tables; |
75 | 78 |
|
76 | | -#[cfg(test)] |
77 | | -mod test; |
78 | 79 | #[doc(hidden)] |
79 | 80 | pub mod __test_api; |
| 81 | +#[cfg(test)] |
| 82 | +mod test; |
80 | 83 |
|
81 | 84 | /// Methods for composing and decomposing characters. |
82 | 85 | pub mod char { |
83 | | - pub use normalize::{decompose_canonical, decompose_compatible, compose}; |
| 86 | + pub use crate::normalize::{compose, decompose_canonical, decompose_compatible}; |
84 | 87 |
|
85 | | - pub use lookups::{canonical_combining_class, is_combining_mark}; |
| 88 | + pub use crate::lookups::{canonical_combining_class, is_combining_mark}; |
86 | 89 | } |
87 | 90 |
|
88 | | - |
89 | 91 | /// Methods for iterating over strings while applying Unicode normalizations |
90 | 92 | /// as described in |
91 | 93 | /// [Unicode Standard Annex #15](http://www.unicode.org/reports/tr15/). |
92 | | -pub trait UnicodeNormalization<I: Iterator<Item=char>> { |
| 94 | +pub trait UnicodeNormalization<I: Iterator<Item = char>> { |
93 | 95 | /// Returns an iterator over the string in Unicode Normalization Form D |
94 | 96 | /// (canonical decomposition). |
95 | | - #[inline] |
96 | 97 | fn nfd(self) -> Decompositions<I>; |
97 | 98 |
|
98 | 99 | /// Returns an iterator over the string in Unicode Normalization Form KD |
99 | 100 | /// (compatibility decomposition). |
100 | | - #[inline] |
101 | 101 | fn nfkd(self) -> Decompositions<I>; |
102 | 102 |
|
103 | 103 | /// An Iterator over the string in Unicode Normalization Form C |
104 | 104 | /// (canonical decomposition followed by canonical composition). |
105 | | - #[inline] |
106 | 105 | fn nfc(self) -> Recompositions<I>; |
107 | 106 |
|
108 | 107 | /// An Iterator over the string in Unicode Normalization Form KC |
109 | 108 | /// (compatibility decomposition followed by canonical composition). |
110 | | - #[inline] |
111 | 109 | fn nfkc(self) -> Recompositions<I>; |
112 | 110 |
|
113 | 111 | /// An Iterator over the string with Conjoining Grapheme Joiner characters |
114 | 112 | /// inserted according to the Stream-Safe Text Process (UAX15-D4) |
115 | | - #[inline] |
116 | 113 | fn stream_safe(self) -> StreamSafe<I>; |
117 | 114 | } |
118 | 115 |
|
@@ -143,7 +140,7 @@ impl<'a> UnicodeNormalization<Chars<'a>> for &'a str { |
143 | 140 | } |
144 | 141 | } |
145 | 142 |
|
146 | | -impl<I: Iterator<Item=char>> UnicodeNormalization<I> for I { |
| 143 | +impl<I: Iterator<Item = char>> UnicodeNormalization<I> for I { |
147 | 144 | #[inline] |
148 | 145 | fn nfd(self) -> Decompositions<I> { |
149 | 146 | decompose::new_canonical(self) |
|
0 commit comments