mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Document selectors::Visit
This commit is contained in:
parent
c14b766ff5
commit
1a6010f19f
2 changed files with 29 additions and 9 deletions
|
@ -44,3 +44,31 @@ pub trait SelectorVisitor {
|
|||
true
|
||||
}
|
||||
}
|
||||
|
||||
/// Enables traversing selector components stored in various types
|
||||
pub trait Visit {
|
||||
/// The type parameter of selector component types.
|
||||
type Impl: SelectorImpl;
|
||||
|
||||
/// Traverse selector components inside `self`.
|
||||
///
|
||||
/// Implementations of this method should call `SelectorVisitor` methods
|
||||
/// or other impls of `Visit` as appropriate based on the fields of `Self`.
|
||||
///
|
||||
/// A return value of `false` indicates terminating the traversal.
|
||||
/// It should be propagated with an early return.
|
||||
/// On the contrary, `true` indicates that all fields of `self` have been traversed:
|
||||
///
|
||||
/// ```rust,ignore
|
||||
/// if !visitor.visit_simple_selector(&self.some_simple_selector) {
|
||||
/// return false;
|
||||
/// }
|
||||
/// if !self.some_component.visit(visitor) {
|
||||
/// return false;
|
||||
/// }
|
||||
/// true
|
||||
/// ```
|
||||
fn visit<V>(&self, visitor: &mut V) -> bool
|
||||
where
|
||||
V: SelectorVisitor<Impl = Self::Impl>;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue