Skip to main content

SelectorList

Struct SelectorList 

Source
pub struct SelectorList(/* private fields */);
Expand description

A comma-separated list of selectors; an element matches if any does.

Implementations§

Source§

impl SelectorList

Source

pub fn parse(selector: &str) -> Result<SelectorList, SelectorError>

Source

pub fn parse_with( selector: &str, opts: &ParseOptions<'_>, ) -> Result<SelectorList, SelectorError>

SelectorList::parse with namespace prefixes declared, as @namespace rules would.

Source

pub fn matches(&self, doc: &Document, el: u32, scope: Option<u32>) -> bool

Whether el matches, with scope as :scope (the root element when None).

Source

pub fn matches_with( &self, doc: &Document, el: u32, scope: Option<u32>, options: &MatchOptions<'_>, ) -> bool

SelectorList::matches with what the document alone can’t say, such as its URL.

Source

pub fn select_with( &self, doc: &Document, scope: u32, options: &MatchOptions<'_>, ) -> Vec<u32>

SelectorList::select with what the document alone can’t say, such as its URL.

Source

pub fn try_select_with( &self, doc: &Document, scope: u32, options: &MatchOptions<'_>, ) -> Result<Vec<u32>, MatchTimeout>

SelectorList::select_with within MatchOptions::budget: an error once it has run out, rather than the matches found so far.

Source

pub fn try_matches_with( &self, doc: &Document, el: u32, scope: Option<u32>, options: &MatchOptions<'_>, ) -> Result<bool, MatchTimeout>

Source

pub fn select(&self, doc: &Document, scope: u32) -> Vec<u32>

The elements under scope that match, in document order. As in a browser, combinators look past scope: article .price run on an article matches the prices inside it.

Source

pub fn select_iter<'a>(&'a self, doc: &'a Document, scope: u32) -> Select<'a> ⓘ

The matches SelectorList::select gives, found one at a time as the iterator is read, so stopping early walks only that far.

Source

pub fn select_first(&self, doc: &Document, scope: u32) -> Option<u32>

The first match in document order, without looking further.

Source

pub fn specificity(&self) -> (u32, u32, u32)

Selectors 4’s specificity, (IDs, classes, types), of the most specific selector in the list, which is how :is() counts one. :is(), :not() and :has() count as their most specific argument, :nth-child(An+B of S) as a class plus S, and :where() as nothing. (|x, which matches nothing, counts a class too much.)

Trait Implementations§

Source§

impl Clone for SelectorList

Source§

fn clone(&self) -> SelectorList

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SelectorList

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.