Trait FeatureConditionList

Source
pub trait FeatureConditionList<'a>: Sized + Parse<'a>
where Self: 'a,
{ type FeatureCondition: Sized + Parse<'a>; // Required methods fn keyword_is_not<I>(p: &Parser<'a, I>, c: Cursor) -> bool where I: Iterator<Item = Cursor> + Clone; fn keyword_is_or<I>(p: &Parser<'a, I>, c: Cursor) -> bool where I: Iterator<Item = Cursor> + Clone; fn keyword_is_and<I>(p: &Parser<'a, I>, c: Cursor) -> bool where I: Iterator<Item = Cursor> + Clone; fn build_is(feature: Self::FeatureCondition) -> Self; fn build_not(keyword: Ident, feature: Self::FeatureCondition) -> Self; fn build_and( features: Vec<'a, (Self::FeatureCondition, Option<Ident>)>, ) -> Self; fn build_or( features: Vec<'a, (Self::FeatureCondition, Option<Ident>)>, ) -> Self; // Provided method fn parse_condition<I>(p: &mut Parser<'a, I>) -> Result<Self> where I: Iterator<Item = Cursor> + Clone { ... } }
Expand description

This trait can be used for AST nodes representing a list of “Feature Conditions”. This is an amalgamation of Supports Conditions, Media Conditions, and Container Queries This is an implementation of <at-rule-list>.

Looking at <supports-condition> and <container-query> we can se almost identical grammars (eliding some tokens for brevity):

<supports-condition>
 │├─╮─ <ident-token "not"> ─ <supports-in-parens> ──────────────────────────────╭──┤│
    ╰─ <supports-in-parens> ─╮─╭─ <ident-token "and"> ─ <supports-in-parens> ─╮─┤
                             │ ╰──────────────────────────────────────────────╯ │
                             ├─╭─ <ident-token "or"> ─ <supports-in-parens> ─╮──┤
                             │ ╰─────────────────────────────────────────────╯  │
                             ╰──────────────────────────────────────────────────╯

<container-query>
 │├─╮─ <ident-token "not"> ─ <query-in-parens> ───────────────────────────╭──┤│
    ╰─ <supports-in-parens> ─╮─╭─ <ident-token "and"> ─ <supports-in-parens> ─╮─┤
                             │ ╰──────────────────────────────────────────────╯ │
                             ├─╭─ <ident-token "or"> ─ <supports-in-parens> ─╮──┤
                             │ ╰─────────────────────────────────────────────╯  │
                             ╰──────────────────────────────────────────────────╯

<media-condition>
 │├─╮─ <ident-token "not"> ─ <media-in-parens> ───────────────────────────╭──┤│
    ╰─ <media-in-parens> ─╮─╭─ <ident-token "and"> ─ <media-in-parens> ─╮─┤
                          │ ╰───────────────────────────────────────────╯ │
                          │─╭─ <ident-token "or"> ─ <media-in-parens> ─╮──│
                          │ ╰──────────────────────────────────────────╯  │
                          ╰───────────────────────────────────────────────╯

The key difference between each of these is their own <*-in-parens> tokens. Thus they could all be defined as:

<condition-prelude-list>
 │├─╮─ <ident-token "not"> ─ <feature> ───────────────────╭──┤│
    ╰─ <feature> ─╮─╭─ <ident-token "and"> ─ <feature> ─╮─┤
                  │ ╰───────────────────────────────────╯ │
                  │─╭─ <ident-token "or"> ─ <feature> ─╮──│
                  │ ╰──────────────────────────────────╯  │
                  ╰───────────────────────────────────────╯

Required Associated Types§

Required Methods§

Source

fn keyword_is_not<I>(p: &Parser<'a, I>, c: Cursor) -> bool
where I: Iterator<Item = Cursor> + Clone,

Source

fn keyword_is_or<I>(p: &Parser<'a, I>, c: Cursor) -> bool
where I: Iterator<Item = Cursor> + Clone,

Source

fn keyword_is_and<I>(p: &Parser<'a, I>, c: Cursor) -> bool
where I: Iterator<Item = Cursor> + Clone,

Source

fn build_is(feature: Self::FeatureCondition) -> Self

Source

fn build_not(keyword: Ident, feature: Self::FeatureCondition) -> Self

Source

fn build_and(features: Vec<'a, (Self::FeatureCondition, Option<Ident>)>) -> Self

Source

fn build_or(features: Vec<'a, (Self::FeatureCondition, Option<Ident>)>) -> Self

Provided Methods§

Source

fn parse_condition<I>(p: &mut Parser<'a, I>) -> Result<Self>
where I: Iterator<Item = Cursor> + Clone,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§