ParserBuilder

Struct ParserBuilder 

Source
pub struct ParserBuilder<'cmt, 's: 'cmt> { /* private fields */ }
Expand description

Parser builder is for building a parser while allowing us to control advanced behaviors.

Unlike Parser, syntax isn’t required when creating a parser builder, and the default syntax will be CSS. If you need to parse with another syntax, use the syntax to modify it.

Implementations§

Source§

impl<'cmt, 's: 'cmt> ParserBuilder<'cmt, 's>

Source

pub fn new(source: &'s str) -> Self

Create a parser builder from given source code.

Source

pub fn syntax(self, syntax: Syntax) -> Self

Specify the syntax for parsing.

Source

pub fn options(self, options: ParserOptions) -> Self

Customize parser options.

Source

pub fn comments(self, comments: &'cmt mut Vec<Comment<'s>>) -> Self

Collect comments and put them into the given collection.

Source

pub fn ignore_comments(self) -> Self

Disable collecting comments.

Collecting comments is disabled by default, so you don’t need to use this if you never call the comments method.

Source

pub fn build(self) -> Parser<'cmt, 's>

Build a parser.

Auto Trait Implementations§

§

impl<'cmt, 's> Freeze for ParserBuilder<'cmt, 's>

§

impl<'cmt, 's> RefUnwindSafe for ParserBuilder<'cmt, 's>

§

impl<'cmt, 's> Send for ParserBuilder<'cmt, 's>

§

impl<'cmt, 's> Sync for ParserBuilder<'cmt, 's>

§

impl<'cmt, 's> Unpin for ParserBuilder<'cmt, 's>

§

impl<'cmt, 's> !UnwindSafe for ParserBuilder<'cmt, 's>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.