Skip to main content

IdSet

Struct IdSet 

Source
pub struct IdSet { /* private fields */ }
Expand description

A set of integer spans.

Implementations§

Source§

impl IdSet

Source

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.

Source

pub fn from_single_span(span: Span) -> Self

Construct a IdSet that contains a single span.

Source

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.

Source

pub fn empty() -> Self

Construct an empty IdSet.

Source

pub fn full() -> Self

Construct a full IdSet that contains everything. Warning: The Id in this set might be unknown to an actual storage.

Source

pub fn is_empty(&self) -> bool

Check if this IdSet contains nothing.

Source

pub fn count(&self) -> u64

Count integers covered by this IdSet.

Source

pub fn contains(&self, value: impl Into<Span>) -> bool

Tests if a given Id or [Span] is covered by this set.

Source

pub fn span_contains(&self, value: impl Into<Span>) -> Option<&Span>

Find the [Span] that covers the given value.

Source

pub fn skip(&self, n: u64) -> Self

Skip the first n items.

Source

pub fn take(&self, n: u64) -> Self

Only take the first n items.

Source

pub fn union(&self, rhs: &IdSet) -> IdSet

Calculates the union of two sets.

Source

pub fn intersection(&self, rhs: &IdSet) -> IdSet

Calculates the intersection of two sets.

Source

pub fn difference(&self, rhs: &IdSet) -> IdSet

Calculates spans that are included only by this set, not rhs.

Source

pub fn iter_desc(&self) -> IdSetIter<&IdSet>

Iterate Ids in descending order.

Source

pub fn iter_asc(&self) -> Rev<IdSetIter<&Self>>

Iterate Ids in ascending order.

Source

pub fn iter_span_desc(&self) -> impl Iterator<Item = &Span>

Iterate Spans in descending order.

Source

pub fn iter_span_asc(&self) -> impl Iterator<Item = &Span>

Iterate Spans in ascending order.

Source

pub fn max(&self) -> Option<Id>

Get the maximum id in this set.

Source

pub fn min(&self) -> Option<Id>

Get the minimal id in this set.

Source

pub fn as_spans(&self) -> &VecDeque<Span>

Get a reference to the spans.

Source

pub fn push(&mut self, span: impl Into<Span>)

Make this IdSet contain the specified span.

The current implementation works best when spans are pushed in ascending or descending order.

Trait Implementations§

Source§

impl Clone for IdSet

Source§

fn clone(&self) -> IdSet

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for IdSet

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for IdSet

Source§

fn default() -> IdSet

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for IdSet

Source§

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 From<(Id, Id)> for IdSet

Source§

fn from(ids: (Id, Id)) -> IdSet

Converts to this type from the input type.
Source§

impl<'a> From<(LegacyCodeNeedIdAccess, &'a IdStaticSet)> for IdSet

Source§

fn from(value: (LegacyCodeNeedIdAccess, &'a IdStaticSet)) -> IdSet

Converts to this type from the input type.
Source§

impl<T: Into<Span>> From<T> for IdSet

Source§

fn from(span: T) -> IdSet

Converts to this type from the input type.
Source§

impl IntoIterator for IdSet

Source§

fn into_iter(self) -> IdSetIter<IdSet>

Get an iterator for integers in this IdSet.

Source§

type Item = Id

The type of the elements being iterated over.
Source§

type IntoIter = IdSetIter<IdSet>

Which kind of iterator are we turning this into?
Source§

impl Serialize for IdSet

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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> 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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> TryClone for T
where T: Clone,

Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,