MCPcopy Index your code
hub / github.com/csskit/csskit / Parse

Interface Parse

crates/css_parse/src/traits/parse.rs:19–31  ·  view source on GitHub ↗

This trait allows AST nodes to construct themselves from a mutable [Parser] instance. Nodes that implement this trait are entitled to consume any number of [Cursors][crate::Cursor] from [Parser] in order to construct themselves. They may also consume some amount of tokens and still return an [Err] - there is no need to try and reset the [Parser] state on failure ([Parser::try_parse()] exists for

Source from the content-addressed store, hash-verified

17/// If a Node can construct itself from a single [Cursor][crate::Cursor] it should implement
18/// [Peek][crate::Peek] and [Parse], where [Parse::parse()] calls [Parser::next()] and constructs from the cursor.
19pub trait Parse<'a>: Sized {
20 fn parse<I>(p: &mut Parser<'a, I>) -> Result<Self>
21 where
22 I: Iterator<Item = Cursor> + Clone;
23
24 fn try_parse<I>(p: &mut Parser<'a, I>) -> Result<Self>
25 where
26 I: Iterator<Item = Cursor> + Clone,
27 {
28 let checkpoint = p.checkpoint();
29 Self::parse(p).inspect_err(|_| p.rewind(checkpoint))
30 }
31}
32
33impl<'a, T> Parse<'a> for Option<T>
34where

Callers

nothing calls this directly

Implementers 15

stylerule.rscrates/css_ast/src/stylerule.rs
stylesheet.rscrates/css_ast/src/stylesheet.rs
lib.rscrates/css_ast/src/lib.rs
constraints.rscrates/css_ast/src/constraints.rs
position.rscrates/css_ast/src/types/position.rs
bg_position.rscrates/css_ast/src/types/bg_position.r
generic_voice.rscrates/css_ast/src/types/generic_voice
grid_line.rscrates/css_ast/src/types/grid_line.rs
cursor_image.rscrates/css_ast/src/types/cursor_image.
single_transition.rscrates/css_ast/src/types/single_transi
display_listitem.rscrates/css_ast/src/types/display_listi
position_area.rscrates/css_ast/src/types/position_area

Calls

no outgoing calls

Tested by

no test coverage detected