Skip to content

Commit af5fd08

Browse files
committed
Added len() method on selector, returning number of subselectors
1 parent 54c5cd6 commit af5fd08

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/selector.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,14 @@ impl Selector {
405405
}
406406
}
407407

408+
/// Returns the number of subselectors under this selector (by definition 0 for simple selectors)
409+
pub fn len(&self) -> usize {
410+
match self {
411+
Selector::MultiSelector(v) | Selector::CompositeSelector(v) | Selector::DirectionalSelector(v) => v.len(),
412+
_ => 0,
413+
}
414+
}
415+
408416
/// Returns the textselection this selector points at, if any
409417
pub fn textselection<'store>(&self, store: &'store AnnotationStore) -> Option<&'store TextSelection> {
410418
match self {

0 commit comments

Comments
 (0)