pipecircuit 0.0.21

Correct. Robust. Fast. Portable. Pick four.
Documentation
use super::SlotSet;

impl SlotSet {
    pub fn union(&self, other: &Self) -> Self {
        Self(&self.0 | &other.0)
    }

    pub fn intersection(&self, other: &Self) -> Self {
        Self(&self.0 & &other.0)
    }

    #[allow(
        clippy::arithmetic_side_effects,
        reason = "Roaring subtraction is infallible set difference, not numeric arithmetic"
    )]
    pub fn excluding(&self, other: &Self) -> Self {
        Self(&self.0 - &other.0)
    }

    pub fn union_excluding_overlap(&self, other: &Self) -> Self {
        Self(&self.0 ^ &other.0)
    }

    pub(crate) fn union_assign(&mut self, other: &Self) {
        self.0 |= &other.0;
    }

    pub(crate) fn intersection_assign(&mut self, other: &Self) {
        self.0 &= &other.0;
    }

    pub(crate) fn intersection_reusing(mut self, other: &Self) -> Self {
        if self.len() <= other.len() {
            self.intersection_assign(other);
            self
        } else {
            other.intersection(&self)
        }
    }

    pub(crate) fn intersection_owned(mut self, mut other: Self) -> Self {
        if self.len() <= other.len() {
            self.intersection_assign(&other);
            self
        } else {
            other.intersection_assign(&self);
            other
        }
    }

    #[allow(
        clippy::arithmetic_side_effects,
        reason = "Roaring subtraction is infallible set difference, not numeric arithmetic"
    )]
    pub(crate) fn exclude_assign(&mut self, other: &Self) {
        self.0 -= &other.0;
    }

    pub(crate) fn union_excluding_overlap_assign(&mut self, other: &Self) {
        self.0 ^= &other.0;
    }

    pub fn is_disjoint(&self, other: &Self) -> bool {
        self.0.is_disjoint(&other.0)
    }

    pub fn is_subset(&self, other: &Self) -> bool {
        self.0.is_subset(&other.0)
    }
}