/// Exhausts the `Classifier` writing the output into `sink`.
///
/// The general structure for this method is to iterate over each token,
/// possibly giving it an HTML span with a class specifying what flavor of
/// token is used.
Exhausts the `Classifier` writing the output into `sink`.
The general structure for this method is to iterate over each token,
possibly giving it an HTML span with a class specifying what flavor of
token is used.
Exhausts the ` Classifier ` writing the output into ` sink ` . The general structure for this method is to iterate over each token possibly giving it an HTML span with a class specifying what flavor of token is used .
fn highlight(mut self, sink: &mut dyn FnMut(Highlight<'a>)) {
        loop {
            if let Some(decs) = self.decorations.as_mut() {
                let byte_pos = self.byte_pos;
                let n_starts = decs.starts.iter().filter(|(i, _)| byte_pos >= *i).count();
                for (_, kind) in decs.starts.drain(0..n_starts) {
                    sink(Highlight::EnterSpan { class: Class::Decoration(kind) });
                }
                let n_ends = decs.ends.iter().filter(|i| byte_pos >= **i).count();
                for _ in decs.ends.drain(0..n_ends) {
                    sink(Highlight::ExitSpan);
                }
            }
            if self
                .tokens
                .peek()
                .map(|t| matches!(t.0, TokenKind::Colon | TokenKind::Ident))
                .unwrap_or(false)
            {
                let tokens = self.get_full_ident_path();
                for (token, start, end) in &tokens {
                    let text = &self.src[*start..*end];
                    self.advance(*token, text, sink, *start as u32);
                    self.byte_pos += text.len() as u32;
                }
                if !tokens.is_empty() {
                    continue;
                }
            }
            if let Some((token, text, before)) = self.next() {
                self.advance(token, text, sink, before);
            } else {
                break;
            }
        }
    }
fn highlight ( mut self , sink : & mut dyn FnMut ( Highlight < ' a > ) ) { loop { if let Some ( decs ) = self . decorations . as_mut ( ) { let byte_pos = self . byte_pos ; let n_starts = decs . starts . iter ( ) . filter ( | ( i , _ ) | byte_pos >= * i ) . count ( ) ; for ( _ , kind ) in decs . starts . drain ( 0 .. n_starts ) { sink ( Highlight :: EnterSpan { class : Class :: Decoration ( kind ) } ) ; } let n_ends = decs . ends . iter ( ) . filter ( | i | byte_pos >= * * i ) . count ( ) ; for _ in decs . ends . drain ( 0 .. n_ends ) { sink ( Highlight :: ExitSpan ) ; } } if self . tokens . peek ( ) . map ( | t | matches ! ( t 0 TokenKind Colon TokenKind Ident ) ) . unwrap_or ( false ) { let tokens = self . get_full_ident_path ( ) ; for ( token , start , end ) in & tokens { let text = & self . src [ * start .. * end ] ; self . advance ( * token , text , sink , * start as u32 ) ; self . byte_pos += text . len ( ) as u32 ; } if ! tokens . is_empty ( ) { continue ; } } if let Some ( ( token , text , before ) ) = self . next ( ) { self . advance ( token , text , sink , before ) ; } else { break ; } } }
Exhausts the `Classifier` writing the output into `sink`.
Exhausts the ` Classifier ` writing the output into ` sink ` .
mut self
sink
&mut dyn FnMut(Highlight<'a>)