pub struct Highlighter {
pub parser: Parser,
/* private fields */
}
Expand description
Performs syntax highlighting, recognizing a given list of highlight names.
For the best performance Highlighter
values should be reused between
syntax highlighting calls. A separate highlighter is needed for each thread that
is performing highlighting.
Fields§
§parser: Parser
Implementations§
Source§impl Highlighter
impl Highlighter
pub fn new() -> Self
pub fn parser(&mut self) -> &mut Parser
Sourcepub fn highlight<'a>(
&'a mut self,
config: &'a HighlightConfiguration,
source: &'a [u8],
cancellation_flag: Option<&'a AtomicUsize>,
injection_callback: impl FnMut(&str) -> Option<&'a HighlightConfiguration> + 'a,
) -> Result<impl Iterator<Item = Result<HighlightEvent, Error>> + 'a, Error>
pub fn highlight<'a>( &'a mut self, config: &'a HighlightConfiguration, source: &'a [u8], cancellation_flag: Option<&'a AtomicUsize>, injection_callback: impl FnMut(&str) -> Option<&'a HighlightConfiguration> + 'a, ) -> Result<impl Iterator<Item = Result<HighlightEvent, Error>> + 'a, Error>
Iterate over the highlighted regions for a given slice of source code.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Highlighter
impl RefUnwindSafe for Highlighter
impl Send for Highlighter
impl Sync for Highlighter
impl Unpin for Highlighter
impl UnwindSafe for Highlighter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more