@@ -47,12 +47,6 @@ pub enum QuickCheck {
4747Maybe ,
4848}
4949
50- /// Result of quickly checking if a string is normalized.
51- pub type QuickResult =Result < QuickCheck , NormalizationError > ;
52-
53- /// Result of authoritatively checking if a string is normalized.
54- pub type FullResult =Result < ( ) , NormalizationError > ;
55-
5650/// Normalization status of single character.
5751pub ( crate ) enum IsNormalized {
5852Yes ,
@@ -62,7 +56,11 @@ pub(crate) enum IsNormalized {
6256
6357// https://unicode.org/reports/tr15/#Detecting_Normalization_Forms
6458#[ inline]
65- fn quick_check < F , I > ( s : I , is_allowed : F , stream_safe : bool ) ->QuickResult
59+ fn quick_check < F , I > (
60+ s : I ,
61+ is_allowed : F ,
62+ stream_safe : bool ,
63+ ) ->Result < QuickCheck , NormalizationError >
6664where
6765I : Iterator < Item =( usize , char ) > ,
6866F : Fn ( char ) ->IsNormalized ,
@@ -112,7 +110,7 @@ where
112110fn full_check < I : Iterator < Item =( usize , char ) > , J : Iterator < Item =char > > (
113111check : I ,
114112normalized : J ,
115- ) ->FullResult {
113+ ) ->Result < ( ) , NormalizationError > {
116114 check. zip ( normalized) . try_for_each ( |( ( idx, lhs) , rhs) |{
117115if lhs == rhs{
118116Ok ( ( ) )
@@ -124,43 +122,43 @@ fn full_check<I: Iterator<Item = (usize, char)>, J: Iterator<Item = char>>(
124122
125123/// Quickly check if a string is in NFC.
126124#[ inline]
127- pub fn check_nfc_quick ( s : & str ) ->QuickResult {
125+ pub fn check_nfc_quick ( s : & str ) ->Result < QuickCheck , NormalizationError > {
128126quick_check ( s. char_indices ( ) , tables:: qc_nfc, false )
129127}
130128
131129/// Quickly check if a string is in NFKC.
132130#[ inline]
133- pub fn check_nfkc_quick ( s : & str ) ->QuickResult {
131+ pub fn check_nfkc_quick ( s : & str ) ->Result < QuickCheck , NormalizationError > {
134132quick_check ( s. char_indices ( ) , tables:: qc_nfkc, false )
135133}
136134
137135/// Quickly check if a string is in NFD.
138136#[ inline]
139- pub fn check_nfd_quick ( s : & str ) ->QuickResult {
137+ pub fn check_nfd_quick ( s : & str ) ->Result < QuickCheck , NormalizationError > {
140138quick_check ( s. char_indices ( ) , tables:: qc_nfd, false )
141139}
142140
143141/// Quickly check if a string is in NFKD.
144142#[ inline]
145- pub fn check_nfkd_quick ( s : & str ) ->QuickResult {
143+ pub fn check_nfkd_quick ( s : & str ) ->Result < QuickCheck , NormalizationError > {
146144quick_check ( s. char_indices ( ) , tables:: qc_nfkd, false )
147145}
148146
149147/// Quickly check if a string is Stream-Safe NFC.
150148#[ inline]
151- pub fn check_nfc_stream_safe_quick ( s : & str ) ->QuickResult {
149+ pub fn check_nfc_stream_safe_quick ( s : & str ) ->Result < QuickCheck , NormalizationError > {
152150quick_check ( s. char_indices ( ) , tables:: qc_nfc, true )
153151}
154152
155153/// Quickly check if a string is Stream-Safe NFD.
156154#[ inline]
157- pub fn check_nfd_stream_safe_quick ( s : & str ) ->QuickResult {
155+ pub fn check_nfd_stream_safe_quick ( s : & str ) ->Result < QuickCheck , NormalizationError > {
158156quick_check ( s. char_indices ( ) , tables:: qc_nfd, true )
159157}
160158
161159/// Authoritatively check if a string is in NFC.
162160#[ inline]
163- pub fn check_nfc ( s : & str ) ->FullResult {
161+ pub fn check_nfc ( s : & str ) ->Result < ( ) , NormalizationError > {
164162match check_nfc_quick ( s) ?{
165163QuickCheck :: Yes =>Ok ( ( ) ) ,
166164QuickCheck :: Maybe =>full_check ( s. char_indices ( ) , s. chars ( ) . nfc ( ) ) ,
@@ -175,7 +173,7 @@ pub fn is_nfc(s: &str) -> bool {
175173
176174/// Authoritatively check if a string is in NFKC.
177175#[ inline]
178- pub fn check_nfkc ( s : & str ) ->FullResult {
176+ pub fn check_nfkc ( s : & str ) ->Result < ( ) , NormalizationError > {
179177match check_nfkc_quick ( s) ?{
180178QuickCheck :: Yes =>Ok ( ( ) ) ,
181179QuickCheck :: Maybe =>full_check ( s. char_indices ( ) , s. chars ( ) . nfkc ( ) ) ,
@@ -190,7 +188,7 @@ pub fn is_nfkc(s: &str) -> bool {
190188
191189/// Authoritatively check if a string is in NFD.
192190#[ inline]
193- pub fn check_nfd ( s : & str ) ->FullResult {
191+ pub fn check_nfd ( s : & str ) ->Result < ( ) , NormalizationError > {
194192match check_nfd_quick ( s) ?{
195193QuickCheck :: Yes =>Ok ( ( ) ) ,
196194QuickCheck :: Maybe =>full_check ( s. char_indices ( ) , s. chars ( ) . nfd ( ) ) ,
@@ -205,7 +203,7 @@ pub fn is_nfd(s: &str) -> bool {
205203
206204/// Authoritatively check if a string is in NFKD.
207205#[ inline]
208- pub fn check_nfkd ( s : & str ) ->FullResult {
206+ pub fn check_nfkd ( s : & str ) ->Result < ( ) , NormalizationError > {
209207match check_nfkd_quick ( s) ?{
210208QuickCheck :: Yes =>Ok ( ( ) ) ,
211209QuickCheck :: Maybe =>full_check ( s. char_indices ( ) , s. chars ( ) . nfkd ( ) ) ,
@@ -220,7 +218,7 @@ pub fn is_nfkd(s: &str) -> bool {
220218
221219/// Authoritatively check if a string is Stream-Safe NFC.
222220#[ inline]
223- pub fn check_nfc_stream_safe ( s : & str ) ->FullResult {
221+ pub fn check_nfc_stream_safe ( s : & str ) ->Result < ( ) , NormalizationError > {
224222match check_nfc_stream_safe_quick ( s) ?{
225223QuickCheck :: Yes =>Ok ( ( ) ) ,
226224QuickCheck :: Maybe =>full_check ( s. char_indices ( ) , s. chars ( ) . stream_safe ( ) . nfc ( ) ) ,
@@ -235,7 +233,7 @@ pub fn is_nfc_stream_safe(s: &str) -> bool {
235233
236234/// Authoritatively check if a string is Stream-Safe NFD.
237235#[ inline]
238- pub fn check_nfd_stream_safe ( s : & str ) ->FullResult {
236+ pub fn check_nfd_stream_safe ( s : & str ) ->Result < ( ) , NormalizationError > {
239237match check_nfd_stream_safe_quick ( s) ?{
240238QuickCheck :: Yes =>Ok ( ( ) ) ,
241239QuickCheck :: Maybe =>full_check ( s. char_indices ( ) , s. chars ( ) . stream_safe ( ) . nfd ( ) ) ,