pub struct CompiledSelector { /* private fields */ }Expand description
A pre-compiled CSS selector for efficient repeated matching.
Compiled selectors avoid the overhead of parsing the selector string on each query. They can be reused across multiple documents and queries.
§Examples
use scrape_core::{Soup, query::CompiledSelector};
let selector = CompiledSelector::compile("div.item > span").unwrap();
let soup = Soup::parse("<div class='item'><span>A</span></div>");
let results = soup.select_compiled(&selector);
assert_eq!(results.len(), 1);Implementations§
Source§impl CompiledSelector
impl CompiledSelector
Sourcepub fn compile(selector: &str) -> QueryResult<Self>
pub fn compile(selector: &str) -> QueryResult<Self>
Sourcepub fn selector_list(&self) -> &SelectorList<ScrapeSelector>
pub fn selector_list(&self) -> &SelectorList<ScrapeSelector>
Returns the underlying selector list for matching.
Trait Implementations§
Source§impl Clone for CompiledSelector
impl Clone for CompiledSelector
Source§fn clone(&self) -> CompiledSelector
fn clone(&self) -> CompiledSelector
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CompiledSelector
impl RefUnwindSafe for CompiledSelector
impl Send for CompiledSelector
impl Sync for CompiledSelector
impl Unpin for CompiledSelector
impl UnwindSafe for CompiledSelector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more