[−][src]Struct rustc_mir_build::thir::pattern::usefulness::SpanSet

pub(crate) struct SpanSet {
    root_spans: Vec<Span>,
}

Represents a set of Spans closed under the containment relation. That is, if a Span is contained in the set then all Spans contained in it are also implicitly contained in the set. In particular this means that when intersecting two sets, taking the intersection of some span and one of its subspans returns the subspan, whereas a simple HashSet would have returned an empty intersection. It is assumed that two spans don't overlap without one being contained in the other; in other words, that the inclusion structure forms a tree and not a DAG. Intersection is not very efficient. It compares everything pairwise. If needed it could be made faster by sorting the Spans and merging cleverly.

Fields

root_spans: Vec<Span>

The minimal set of Spans required to represent the whole set. If A and B are Spans in the SpanSet, and A is a descendant of B, then only B will be in root_spans. Invariant: the spans are disjoint.

Implementations

impl SpanSet[src]

fn new() -> Self[src]

Creates an empty set.

pub(crate) fn is_empty(&self) -> bool[src]

Tests whether the set is empty.

pub(crate) fn iter<'a>(&'a self) -> impl Iterator<Item = Span> + Captures<'a>[src]

Iterate over the disjoint list of spans at the roots of this set.

fn contains(&self, span: Span) -> bool[src]

Tests whether the set contains a given Span.

fn push_nonintersecting(&mut self, new_span: Span)[src]

Add a span to the set if we know the span has no intersection in this set.

fn intersection_mut(&mut self, other: &Self)[src]

Trait Implementations

impl Clone for SpanSet[src]

impl Debug for SpanSet[src]

impl Default for SpanSet[src]

Auto Trait Implementations

impl RefUnwindSafe for SpanSet[src]

impl !Send for SpanSet[src]

impl !Sync for SpanSet[src]

impl Unpin for SpanSet[src]

impl UnwindSafe for SpanSet[src]

Blanket Implementations

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

impl<T> Borrow<T> for T where
    T: ?Sized, 
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized, 
[src]

impl<'a, T> Captures<'a> for T where
    T: ?Sized, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone, 
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.