pub struct Css<'a>(pub Vec<FlatRuleset<'a>>);Expand description
A non-nested “flat” CSS representation, suitable for browser output. The
Css AST is typically generated via the
crate::ast::Tree::flatten_tree method.
Tuple Fields§
§0: Vec<FlatRuleset<'a>>Implementations§
source§impl<'a> Css<'a>
impl<'a> Css<'a>
sourcepub fn transform<T>(&mut self, f: impl FnMut(&mut T))where
Self: TransformCss<T>,
pub fn transform<T>(&mut self, f: impl FnMut(&mut T))where
Self: TransformCss<T>,
A mutable transform which walks this AST recursively, invoking f for
all nodes of type T.
Example
use procss::{ast, parse, RenderCss};
let mut css = parse("div{color: red;}").unwrap().flatten_tree();
css.transform(|rule: &mut ast::Rule| {
rule.value = "green".into();
});
assert_eq!(css.as_css_string(), "div{color:green;}");sourcepub fn iter(&self) -> impl Iterator<Item = &FlatRuleset<'a>>
pub fn iter(&self) -> impl Iterator<Item = &FlatRuleset<'a>>
Iterate over the immediate children of this Tree (non-recursive).