Skip to content

Commit 1fe60fa

Browse files
committed
Remove result aliases
1 parent eb6544e commit 1fe60fa

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub use crate::quick_check::{
5757
check_nfc, check_nfc_quick, check_nfc_stream_safe, check_nfc_stream_safe_quick, check_nfd,
5858
check_nfd_quick, check_nfd_stream_safe, check_nfd_stream_safe_quick, check_nfkc,
5959
check_nfkc_quick, check_nfkd, check_nfkd_quick, is_nfc, is_nfc_stream_safe, is_nfd,
60-
is_nfd_stream_safe, is_nfkc, is_nfkd, FullResult, NormalizationError, QuickCheck, QuickResult,
60+
is_nfd_stream_safe, is_nfkc, is_nfkd, NormalizationError, QuickCheck,
6161
};
6262
pub use crate::recompose::Recompositions;
6363
pub use crate::replace::Replacements;

src/quick_check.rs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,6 @@ pub enum QuickCheck {
4747
Maybe,
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.
5751
pub(crate) enum IsNormalized {
5852
Yes,
@@ -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>
6664
where
6765
I: Iterator<Item = (usize, char)>,
6866
F: Fn(char) -> IsNormalized,
@@ -112,7 +110,7 @@ where
112110
fn full_check<I: Iterator<Item = (usize, char)>, J: Iterator<Item = char>>(
113111
check: I,
114112
normalized: J,
115-
) -> FullResult {
113+
) -> Result<(), NormalizationError> {
116114
check.zip(normalized).try_for_each(|((idx, lhs), rhs)| {
117115
if lhs == rhs {
118116
Ok(())
@@ -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> {
128126
quick_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> {
134132
quick_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> {
140138
quick_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> {
146144
quick_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> {
152150
quick_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> {
158156
quick_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> {
164162
match check_nfc_quick(s)? {
165163
QuickCheck::Yes => Ok(()),
166164
QuickCheck::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> {
179177
match check_nfkc_quick(s)? {
180178
QuickCheck::Yes => Ok(()),
181179
QuickCheck::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> {
194192
match check_nfd_quick(s)? {
195193
QuickCheck::Yes => Ok(()),
196194
QuickCheck::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> {
209207
match check_nfkd_quick(s)? {
210208
QuickCheck::Yes => Ok(()),
211209
QuickCheck::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> {
224222
match check_nfc_stream_safe_quick(s)? {
225223
QuickCheck::Yes => Ok(()),
226224
QuickCheck::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> {
239237
match check_nfd_stream_safe_quick(s)? {
240238
QuickCheck::Yes => Ok(()),
241239
QuickCheck::Maybe => full_check(s.char_indices(), s.chars().stream_safe().nfd()),

0 commit comments

Comments
 (0)