pub struct AtRule<AT, P, B>{
pub name: AtKeyword,
pub prelude: P,
pub block: B,
pub semicolon: Option<Semicolon>,
/* private fields */
}
Expand description
This struct provides the generic <at-rule>
grammar. It will consume an at-rule. This is defined as:
<at-rule>
│├─ <AT> ─ <P> ─ <B> ─╭───────╮┤│
╰─ ";" ─╯
<AT>
must implement Peek, Parse, and Into<token_macros::AtKeyword>
. This helps enforce that this is an
at-rule, that the first token has to be a specific AtKeyword.
<P>
- the prelude - must implement Parse, ToCursors, and ToSpan. To make the prelude optional simply use an
Option. To enforce no prelude the NoPreludeAllowed type can be used. Non-optional
types are considered required.
<B>
- the block - must implement Parse, ToCursors, and ToSpan. To make the block optional simply use an
Option. To enforce no block the NoBlockAllowed type can be used. Non-optional types are
considered required. Ideally the block should implement one of Block,
DeclarationList, or DeclarationRuleList.
A generic AtRule could be AtRule<T![AtKeyword], ComponentValues<'a>, SimpleBlock>
.
To specify extra restrictions on the value of the at-keyword, use atkeyword_set.
§Example
use css_parse::*;
/// A grammar like `@test foo {}`
#[derive(Debug)]
pub struct TestAtRule<'a>(AtRule<T![AtKeyword], T![Ident], SimpleBlock<'a>>);
impl<'a> Parse<'a> for TestAtRule<'a> {
fn parse(p: &mut Parser<'a>) -> Result<Self> {
Ok(Self(p.parse::<AtRule<T![AtKeyword], T![Ident], SimpleBlock<'a>>>()?))
}
}
impl ToCursors for TestAtRule<'_> {
fn to_cursors(&self, s: &mut impl CursorSink) {
self.0.to_cursors(s);
}
}
assert_parse!(TestAtRule, "@test foo{}");
Fields§
§name: AtKeyword
§prelude: P
§block: B
§semicolon: Option<Semicolon>
Trait Implementations§
Source§impl<AT, P: Ord, B: Ord> Ord for AtRule<AT, P, B>
impl<AT, P: Ord, B: Ord> Ord for AtRule<AT, P, B>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<AT, P: PartialOrd, B: PartialOrd> PartialOrd for AtRule<AT, P, B>
impl<AT, P: PartialOrd, B: PartialOrd> PartialOrd for AtRule<AT, P, B>
Source§impl<AT, P, B> ToCursors for AtRule<AT, P, B>
impl<AT, P, B> ToCursors for AtRule<AT, P, B>
fn to_cursors(&self, s: &mut impl CursorSink)
impl<AT, P: Eq, B: Eq> Eq for AtRule<AT, P, B>
impl<AT, P, B> StructuralPartialEq for AtRule<AT, P, B>
Auto Trait Implementations§
impl<AT, P, B> Freeze for AtRule<AT, P, B>
impl<AT, P, B> RefUnwindSafe for AtRule<AT, P, B>
impl<AT, P, B> Send for AtRule<AT, P, B>
impl<AT, P, B> Sync for AtRule<AT, P, B>
impl<AT, P, B> Unpin for AtRule<AT, P, B>
impl<AT, P, B> UnwindSafe for AtRule<AT, P, B>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg
] or
a color-specific method, such as [OwoColorize::green
], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg
] or
a color-specific method, such as [OwoColorize::on_yellow
], Read more