Skip to main content

highlight

Function highlight 

Source
pub fn highlight(source: &str) -> Result<Vec<Token>>
Expand description

Classify all of source.

The tokens are in order and cover every byte exactly once. If the source stops lexing partway through, the rest of it is one Class::Error token.

ยงExamples

use rune::highlight::{highlight, Class};

let tokens = highlight("fn main() {}")?;
assert_eq!(tokens[0].class, Class::Keyword);