lewp_css/domain/at_rules/counter_style/
fallback.rs

1use {
2    crate::{
3        domain::CounterStyleIdent,
4        parsers::{Parse, ParserContext},
5        CustomParseError,
6    },
7    cssparser::{ParseError, Parser, ToCss},
8    std::fmt,
9};
10
11// This file is part of css. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/css/master/COPYRIGHT. No part of predicator, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
12// Copyright © 2017 The developers of css. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/css/master/COPYRIGHT.
13
14/// <https://drafts.csswg.org/css-counter-styles/#counter-style-fallback>
15#[derive(Clone, Debug)]
16pub struct Fallback(pub CounterStyleIdent);
17
18impl ToCss for Fallback {
19    fn to_css<W: fmt::Write>(&self, dest: &mut W) -> fmt::Result {
20        self.0.to_css(dest)
21    }
22}
23
24impl Parse for Fallback {
25    #[inline(always)]
26    fn parse<'i, 't>(
27        _context: &ParserContext,
28        input: &mut Parser<'i, 't>,
29    ) -> Result<Self, ParseError<'i, CustomParseError<'i>>> {
30        CounterStyleIdent::parse(input).map(Fallback)
31    }
32}