css_parse/
parser_return.rs1use crate::{Cursor, CursorSink, Error, ToCursors};
2
3#[derive(Debug)]
4pub struct ParserReturn<'a, T>
5where
6 T: ToCursors,
7{
8 pub output: Option<T>,
9 pub source_text: &'a str,
10 pub errors: Vec<Error>,
11 pub trivia: Vec<Cursor>,
12 with_trivia: bool,
13}
14
15impl<'a, T: ToCursors> ParserReturn<'a, T> {
16 pub fn new(output: Option<T>, source_text: &'a str, errors: Vec<Error>, trivia: Vec<Cursor>) -> Self {
17 Self { output, source_text, errors, trivia, with_trivia: false }
18 }
19
20 pub fn with_trivia(mut self) -> Self {
21 self.with_trivia = true;
22 self
23 }
24}
25
26impl<T: ToCursors> ToCursors for ParserReturn<'_, T> {
27 fn to_cursors(&self, s: &mut impl CursorSink) {
28 if let Some(output) = &self.output {
29 let sink = if self.with_trivia { todo!() } else { s };
30 ToCursors::to_cursors(output, sink);
31 }
32 }
33}