diff --git a/src/decompose.rs b/src/decompose.rs index f945de3..2c73383 100644 --- a/src/decompose.rs +++ b/src/decompose.rs @@ -36,23 +36,33 @@ pub struct Decompositions { ready: Range, } -#[inline] -pub fn new_canonical>(iter: I) -> Decompositions { - Decompositions { - kind: self::DecompositionType::Canonical, - iter: iter.fuse(), - buffer: TinyVec::new(), - ready: 0..0, +impl> Decompositions { + /// Create a new decomposition iterator for canonical decompositions (NFD) + /// + /// Note that this iterator can also be obtained by directly calling [`.nfd()`](crate::UnicodeNormalization::nfd) + /// on the iterator. + #[inline] + pub fn new_canonical(iter: I) -> Decompositions { + Decompositions { + kind: self::DecompositionType::Canonical, + iter: iter.fuse(), + buffer: TinyVec::new(), + ready: 0..0, + } } -} -#[inline] -pub fn new_compatible>(iter: I) -> Decompositions { - Decompositions { - kind: self::DecompositionType::Compatible, - iter: iter.fuse(), - buffer: TinyVec::new(), - ready: 0..0, + /// Create a new decomposition iterator for compatability decompositions (NFkD) + /// + /// Note that this iterator can also be obtained by directly calling [`.nfd()`](crate::UnicodeNormalization::nfd) + /// on the iterator. + #[inline] + pub fn new_compatible(iter: I) -> Decompositions { + Decompositions { + kind: self::DecompositionType::Compatible, + iter: iter.fuse(), + buffer: TinyVec::new(), + ready: 0..0, + } } } diff --git a/src/lib.rs b/src/lib.rs index cc0a850..6c5e029 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -133,22 +133,22 @@ pub trait UnicodeNormalization> { impl<'a> UnicodeNormalization> for &'a str { #[inline] fn nfd(self) -> Decompositions> { - decompose::new_canonical(self.chars()) + Decompositions::new_canonical(self.chars()) } #[inline] fn nfkd(self) -> Decompositions> { - decompose::new_compatible(self.chars()) + Decompositions::new_compatible(self.chars()) } #[inline] fn nfc(self) -> Recompositions> { - recompose::new_canonical(self.chars()) + Recompositions::new_canonical(self.chars()) } #[inline] fn nfkc(self) -> Recompositions> { - recompose::new_compatible(self.chars()) + Recompositions::new_compatible(self.chars()) } #[inline] @@ -165,22 +165,22 @@ impl<'a> UnicodeNormalization> for &'a str { impl UnicodeNormalization> for char { #[inline] fn nfd(self) -> Decompositions> { - decompose::new_canonical(Some(self).into_iter()) + Decompositions::new_canonical(Some(self).into_iter()) } #[inline] fn nfkd(self) -> Decompositions> { - decompose::new_compatible(Some(self).into_iter()) + Decompositions::new_compatible(Some(self).into_iter()) } #[inline] fn nfc(self) -> Recompositions> { - recompose::new_canonical(Some(self).into_iter()) + Recompositions::new_canonical(Some(self).into_iter()) } #[inline] fn nfkc(self) -> Recompositions> { - recompose::new_compatible(Some(self).into_iter()) + Recompositions::new_compatible(Some(self).into_iter()) } #[inline] @@ -197,22 +197,22 @@ impl UnicodeNormalization> for char { impl> UnicodeNormalization for I { #[inline] fn nfd(self) -> Decompositions { - decompose::new_canonical(self) + Decompositions::new_canonical(self) } #[inline] fn nfkd(self) -> Decompositions { - decompose::new_compatible(self) + Decompositions::new_compatible(self) } #[inline] fn nfc(self) -> Recompositions { - recompose::new_canonical(self) + Recompositions::new_canonical(self) } #[inline] fn nfkc(self) -> Recompositions { - recompose::new_compatible(self) + Recompositions::new_compatible(self) } #[inline] diff --git a/src/recompose.rs b/src/recompose.rs index 4268b0b..4effa86 100644 --- a/src/recompose.rs +++ b/src/recompose.rs @@ -32,25 +32,35 @@ pub struct Recompositions { last_ccc: Option, } -#[inline] -pub fn new_canonical>(iter: I) -> Recompositions { - Recompositions { - iter: super::decompose::new_canonical(iter), - state: self::RecompositionState::Composing, - buffer: TinyVec::new(), - composee: None, - last_ccc: None, +impl> Recompositions { + /// Create a new recomposition iterator for canonical compositions (NFC) + /// + /// Note that this iterator can also be obtained by directly calling [`.nfc()`](crate::UnicodeNormalization::nfc) + /// on the iterator. + #[inline] + pub fn new_canonical(iter: I) -> Self { + Recompositions { + iter: Decompositions::new_canonical(iter), + state: self::RecompositionState::Composing, + buffer: TinyVec::new(), + composee: None, + last_ccc: None, + } } -} -#[inline] -pub fn new_compatible>(iter: I) -> Recompositions { - Recompositions { - iter: super::decompose::new_compatible(iter), - state: self::RecompositionState::Composing, - buffer: TinyVec::new(), - composee: None, - last_ccc: None, + /// Create a new recomposition iterator for compatability compositions (NFkC) + /// + /// Note that this iterator can also be obtained by directly calling [`.nfkc()`](crate::UnicodeNormalization::nfkc) + /// on the iterator. + #[inline] + pub fn new_compatible(iter: I) -> Self { + Recompositions { + iter: Decompositions::new_compatible(iter), + state: self::RecompositionState::Composing, + buffer: TinyVec::new(), + composee: None, + last_ccc: None, + } } }