pub struct Position {
pub index: usize,
pub sibling_count: usize,
pub parent_type: Option<String>,
pub of_type_index: usize,
pub of_type_count: usize,
}Expand description
Where an element sits among its siblings. Used by structural pseudo-class
matching (:nth-child, :first-of-type, etc.); returned by
StyledNode::position for forward-compat.
Fields§
§index: usize0-based index among siblings.
sibling_count: usizeTotal number of siblings (including self).
parent_type: Option<String>The parent element’s type name, if any.
of_type_index: usize0-based index of this element among its same-type siblings (those sharing
type_name). 0 means “unknown / not supplied” — of-type pseudo-classes
that need the total count (:last/only/nth-last-of-type) will NOT match
when this is 0. (0-based, like index.) Supply it via
with_of_type.
of_type_count: usizeTotal number of same-type siblings (including self). 0 means “unknown”.
The forward-looking of-type pseudos (:last/only/nth-last-of-type)
require this to be > 0 to match. :nth-of-type / :first-of-type will
prefer this when > 0 but fall back to previous-sibling counting
otherwise. Supply it via with_of_type.
Implementations§
Source§impl Position
impl Position
pub fn new(index: usize, sibling_count: usize) -> Self
Sourcepub fn with_of_type(self, of_type_index: usize, of_type_count: usize) -> Self
pub fn with_of_type(self, of_type_index: usize, of_type_count: usize) -> Self
Consuming builder that sets the same-type-sibling position info.
of_type_index is 0-based among same-type siblings; of_type_count is
the total same-type sibling count (including self). Both 0 (the
default) mean “unknown” — in that state :last/only/nth-last-of-type
never match.
Trait Implementations§
impl Eq for Position
impl StructuralPartialEq for Position
Auto Trait Implementations§
impl Freeze for Position
impl RefUnwindSafe for Position
impl Send for Position
impl Sync for Position
impl Unpin for Position
impl UnsafeUnpin for Position
impl UnwindSafe for Position
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more