pub struct IsizeCO { /* private fields */ }Implementations§
Source§impl IsizeCO
impl IsizeCO
pub const fn try_new(start: isize, end_excl: isize) -> Option<Self>
pub const unsafe fn new_unchecked(start: isize, end_excl: isize) -> Self
Sourcepub const fn checked_from_midpoint_len(mid: isize, len: usize) -> Option<Self>
pub const fn checked_from_midpoint_len(mid: isize, len: usize) -> Option<Self>
Constructs an IsizeCO interval from a midpoint and length (usize).
§Parameters
mid: the desired midpoint of the intervallen: the desired length of the interval in units, must be1..=usize::MAX
§Returns
Some(IsizeCO)if the interval[start, end_excl)can be represented inisizeNoneiflen = 0or the computedstart/end_exclwould overflowisize
§Guarantees
- Returned interval satisfies
start < end_excl - Maximum accepted input length is
usize::MAX
Sourcepub const fn saturating_from_midpoint_len(
mid: isize,
len: usize,
) -> Option<Self>
pub const fn saturating_from_midpoint_len( mid: isize, len: usize, ) -> Option<Self>
Constructs an IsizeCO interval from a midpoint and length (usize) with saturating semantics.
§Parameters
mid: the desired midpoint of the intervallen: the desired length of the interval in units, must be1..=usize::MAX
§Behavior
- Values are saturated at
isize::MIN/isize::MAXto prevent overflow. - If
len = 0, returnsNone.
§Guarantees
- Returned interval satisfies
start < end_excl - Maximum accepted input length is
usize::MAX - Fully compatible with codegen for other signed integer interval types
Source§impl IsizeCO
impl IsizeCO
pub const fn start(self) -> isize
pub const fn end_excl(self) -> isize
pub const fn end_incl(self) -> isize
pub const fn len(self) -> usize
Sourcepub const fn midpoint(self) -> isize
pub const fn midpoint(self) -> isize
Returns the midpoint of the interval [start, end_excl),
using floor division if the length is even.
§Guarantees
midpoint()∈[self.start, self.end_excl - 1]- Works for intervals with maximum length (entire
isizerange)
pub const fn contains(self, x: isize) -> bool
pub const fn contains_interval(self, other: Self) -> bool
pub const fn iter(self) -> Range<isize>
pub const fn to_range(self) -> Range<isize>
pub const fn intersects(self, other: Self) -> bool
pub const fn is_adjacent(self, other: Self) -> bool
pub const fn is_contiguous_with(self, other: Self) -> bool
Source§impl IsizeCO
impl IsizeCO
Sourcepub const fn intersection(self, other: Self) -> Option<Self>
pub const fn intersection(self, other: Self) -> Option<Self>
Returns the intersection of two intervals.
If the intervals do not overlap, returns None.
Sourcepub const fn convex_hull(self, other: Self) -> Self
pub const fn convex_hull(self, other: Self) -> Self
Returns the convex hull (smallest interval containing both) of two intervals.
Always returns a valid IsizeCO.
Sourcepub const fn between(self, other: Self) -> Option<Self>
pub const fn between(self, other: Self) -> Option<Self>
Returns the interval strictly between two intervals.
If the intervals are contiguous or overlap, returns None.
Sourcepub const fn union(self, other: Self) -> OneTwo<Self>
pub const fn union(self, other: Self) -> OneTwo<Self>
Returns the union of two intervals.
- If intervals are contiguous or overlapping, returns
Onecontaining the merged interval. - Otherwise, returns
Twocontaining both intervals in ascending order.
Sourcepub const fn difference(self, other: Self) -> ZeroOneTwo<Self>
pub const fn difference(self, other: Self) -> ZeroOneTwo<Self>
Returns the difference of two intervals (self - other).
- If no overlap, returns
One(self). - If partial overlap, returns
OneorTwodepending on remaining segments. - If fully contained, returns
Zero.
Sourcepub const fn symmetric_difference(self, other: Self) -> ZeroOneTwo<Self>
pub const fn symmetric_difference(self, other: Self) -> ZeroOneTwo<Self>
Returns the symmetric difference of two intervals.
Equivalent to (self - other) ∪ (other - self).
- If intervals do not overlap, returns
Two(self, other)in order. - If intervals partially overlap, returns remaining non-overlapping segments as
OneorTwo.
Source§impl IsizeCO
impl IsizeCO
pub const fn checked_minkowski_add(self, other: Self) -> Option<Self>
pub const fn checked_minkowski_sub(self, other: Self) -> Option<Self>
pub const fn checked_minkowski_mul(self, other: Self) -> Option<Self>
pub const fn checked_minkowski_div(self, other: Self) -> Option<Self>
Source§impl IsizeCO
impl IsizeCO
pub const fn checked_minkowski_add_n(self, n: isize) -> Option<Self>
pub const fn checked_minkowski_sub_n(self, n: isize) -> Option<Self>
pub const fn checked_minkowski_mul_n(self, n: isize) -> Option<Self>
pub const fn checked_minkowski_div_n(self, n: isize) -> Option<Self>
Source§impl IsizeCO
impl IsizeCO
pub const fn saturating_minkowski_add(self, other: Self) -> Option<Self>
pub const fn saturating_minkowski_sub(self, other: Self) -> Option<Self>
pub const fn saturating_minkowski_mul(self, other: Self) -> Option<Self>
pub const fn saturating_minkowski_div(self, other: Self) -> Option<Self>
Source§impl IsizeCO
impl IsizeCO
pub const fn saturating_minkowski_add_n(self, n: isize) -> Option<Self>
pub const fn saturating_minkowski_sub_n(self, n: isize) -> Option<Self>
pub const fn saturating_minkowski_mul_n(self, n: isize) -> Option<Self>
pub const fn saturating_minkowski_div_n(self, n: isize) -> Option<Self>
Trait Implementations§
Source§impl Ord for IsizeCO
impl Ord for IsizeCO
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for IsizeCO
impl PartialOrd for IsizeCO
impl Copy for IsizeCO
impl Eq for IsizeCO
impl StructuralPartialEq for IsizeCO
Auto Trait Implementations§
impl Freeze for IsizeCO
impl RefUnwindSafe for IsizeCO
impl Send for IsizeCO
impl Sync for IsizeCO
impl Unpin for IsizeCO
impl UnsafeUnpin for IsizeCO
impl UnwindSafe for IsizeCO
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