pub struct IdSet { /* private fields */ }Expand description
A set of integer spans.
Implementations§
Source§impl IdSet
impl IdSet
Sourcepub fn from_spans<T: Into<Span>, I: IntoIterator<Item = T>>(spans: I) -> Self
pub fn from_spans<T: Into<Span>, I: IntoIterator<Item = T>>(spans: I) -> Self
Construct a IdSet containing given spans.
Overlapped or adjacent spans will be merged automatically.
Sourcepub fn from_single_span(span: Span) -> Self
pub fn from_single_span(span: Span) -> Self
Construct a IdSet that contains a single span.
Sourcepub fn from_sorted_spans<T: Into<Span>, I: IntoIterator<Item = T>>(
span_iter: I,
) -> Self
pub fn from_sorted_spans<T: Into<Span>, I: IntoIterator<Item = T>>( span_iter: I, ) -> Self
Construct a IdSet containing given spans.
The given spans must be already sorted (i.e. larger ids first), and do
not have overlapped spans.
Adjacent spans will be merged automatically.
Sourcepub fn contains(&self, value: impl Into<Span>) -> bool
pub fn contains(&self, value: impl Into<Span>) -> bool
Tests if a given Id or [Span] is covered by this set.
Sourcepub fn span_contains(&self, value: impl Into<Span>) -> Option<&Span>
pub fn span_contains(&self, value: impl Into<Span>) -> Option<&Span>
Find the [Span] that covers the given value.
Sourcepub fn intersection(&self, rhs: &IdSet) -> IdSet
pub fn intersection(&self, rhs: &IdSet) -> IdSet
Calculates the intersection of two sets.
Sourcepub fn difference(&self, rhs: &IdSet) -> IdSet
pub fn difference(&self, rhs: &IdSet) -> IdSet
Calculates spans that are included only by this set, not rhs.
Sourcepub fn iter_span_desc(&self) -> impl Iterator<Item = &Span>
pub fn iter_span_desc(&self) -> impl Iterator<Item = &Span>
Iterate Spans in descending order.
Sourcepub fn iter_span_asc(&self) -> impl Iterator<Item = &Span>
pub fn iter_span_asc(&self) -> impl Iterator<Item = &Span>
Iterate Spans in ascending order.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for IdSet
impl<'de> Deserialize<'de> for IdSet
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<'a> From<(LegacyCodeNeedIdAccess, &'a IdStaticSet)> for IdSet
impl<'a> From<(LegacyCodeNeedIdAccess, &'a IdStaticSet)> for IdSet
Source§fn from(value: (LegacyCodeNeedIdAccess, &'a IdStaticSet)) -> IdSet
fn from(value: (LegacyCodeNeedIdAccess, &'a IdStaticSet)) -> IdSet
Converts to this type from the input type.
Source§impl IntoIterator for IdSet
impl IntoIterator for IdSet
Auto Trait Implementations§
impl Freeze for IdSet
impl RefUnwindSafe for IdSet
impl Send for IdSet
impl Sync for IdSet
impl Unpin for IdSet
impl UnsafeUnpin for IdSet
impl UnwindSafe for IdSet
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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