Skip to main content

parse_events

Function parse_events 

Source
pub fn parse_events(
    input: &str,
) -> impl Iterator<Item = Result<(Event<'_>, Span), Error>> + '_
Expand description

Parse a YAML string into a lazy event stream.

The iterator yields Result<(Event, Span), Error> items. The first event is always Event::StreamStart and the last is always Event::StreamEnd.

ยงExample

use rlsp_yaml_parser::{parse_events, Event};

let events: Vec<_> = parse_events("").collect();
assert!(matches!(events.first(), Some(Ok((Event::StreamStart, _)))));
assert!(matches!(events.last(), Some(Ok((Event::StreamEnd, _)))));