pub trait Visit<'i, T: Visit<'i, T, V>, V: ?Sized + Visitor<'i, T>> {
const CHILD_TYPES: VisitTypes;
// Required method
fn visit_children(&mut self, visitor: &mut V) -> Result<(), V::Error>;
// Provided method
fn visit(&mut self, visitor: &mut V) -> Result<(), V::Error> { ... }
}Available on crate feature
visitor only.Expand description
A trait for values that can be visited by a Visitor.
Required Associated Constants§
Sourceconst CHILD_TYPES: VisitTypes
const CHILD_TYPES: VisitTypes
The types of values contained within this value and its children. This is used to skip branches that don’t have any values requested by the Visitor.
Required Methods§
Provided Methods§
Sourcefn visit(&mut self, visitor: &mut V) -> Result<(), V::Error>
fn visit(&mut self, visitor: &mut V) -> Result<(), V::Error>
Visits the value by calling an appropriate method on the Visitor. If no corresponding visitor method exists, then the children are visited.
Examples found in repository?
examples/custom_at_rule.rs (lines 37-39)
23fn main() {
24 let args: Vec<String> = std::env::args().collect();
25 let source = std::fs::read_to_string(&args[1]).unwrap();
26 let opts = ParserOptions {
27 filename: args[1].clone(),
28 ..Default::default()
29 };
30
31 let mut stylesheet = StyleSheet::parse_with(&source, opts, &mut TailwindAtRuleParser).unwrap();
32
33 println!("{:?}", stylesheet);
34
35 let mut style_rules = HashMap::new();
36 stylesheet
37 .visit(&mut StyleRuleCollector {
38 rules: &mut style_rules,
39 })
40 .unwrap();
41 println!("{:?}", style_rules);
42 stylesheet.visit(&mut ApplyVisitor { rules: &style_rules }).unwrap();
43
44 let result = stylesheet
45 .to_css(PrinterOptions {
46 targets: Browsers {
47 chrome: Some(100 << 16),
48 ..Browsers::default()
49 }
50 .into(),
51 ..PrinterOptions::default()
52 })
53 .unwrap();
54 println!("{}", result.code);
55}Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".