pub trait Selectable<'a> {
type Select<'b>: Iterator<Item = ElementRef<'a>>;
// Required method
fn select(self, selector: &Selector) -> Self::Select<'_>;
}
Expand description
Trait to abstract over collections of elements to which a CSS selector can be applied
The mainly enables writing helper functions which are generic over Html
and ElementRef
, e.g.
use scraper::{selectable::Selectable, selector::Selector};
fn text_of_first_match<'a, S>(selectable: S, selector: &Selector) -> Option<String>
where
S: Selectable<'a>,
{
selectable.select(selector).next().map(|element| element.text().collect())
}
Required Associated Types§
Sourcetype Select<'b>: Iterator<Item = ElementRef<'a>>
type Select<'b>: Iterator<Item = ElementRef<'a>>
Iterator over element references matching a [CSS selectorSelector
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.