basic_text_internals/
pre_normalization.rs

1use crate::{BasicTextError, Categorize, IsolateUnassigned};
2use std::cell::RefCell;
3use std::rc::Rc;
4
5/// An extension crate providing iterator transforms useful before
6/// normalization.
7pub trait PreNormalization<I: Iterator<Item = char>> {
8    /// Return an iterator which detects some sequences which are not valid in
9    /// Basic Text.
10    fn categorize(self, error: Rc<RefCell<Option<BasicTextError>>>) -> Categorize<I>;
11
12    /// Return an iterator that inserts CGJs around unassigned scalar values to
13    /// protect them from future normalization.
14    fn isolate_unassigned(self) -> IsolateUnassigned<I>;
15}
16
17impl<I: Iterator<Item = char>> PreNormalization<I> for I {
18    #[inline]
19    fn categorize(self, error: Rc<RefCell<Option<BasicTextError>>>) -> Categorize<I> {
20        Categorize::new(self, error)
21    }
22
23    #[inline]
24    fn isolate_unassigned(self) -> IsolateUnassigned<I> {
25        IsolateUnassigned::new(self)
26    }
27}