Struct axgeom::Range

source ·
pub struct Range<T> {
    pub start: T,
    pub end: T,
}
Expand description

A 1D range. Internally represented as start and end. (as opposed to a start and length) If range A contains value x and range B contains value x, then A intersects B. There is no protection against “degenerate” Ranges where start>end.

A point is consindered inside of a range if the point is in [start,end].

Fields§

§start: T§end: T

Implementations§

source§

impl<T> Range<T>

source

pub fn new(start: T, end: T) -> Range<T>

source§

impl<T: Copy + Ord + Sub<Output = T> + Signed> Range<T>

source

pub fn distance_to_point(&self, pos: T) -> Option<T>

source

pub fn difference_to_point(&self, pos: T) -> Option<T>

Positive if point is to the right of the range. Negative if point is to the left of range.

source§

impl<T: Copy + PartialOrd> Range<T>

source

pub fn contains_ext(&self, pos: T) -> Ordering

Like contains() but returns Ord. If the pos is strictly less than the range.start, return less. If the pos is greater of equal to the range.end, return greater. else, return equal.

source

pub fn contains(&self, pos: T) -> bool

Returns true if the point is inside of the range or on top of.

source

pub fn subdivide(&self, divider: T) -> (Range<T>, Range<T>)

Subdivides the range. No floating point calculations are done.

source

pub fn is_valid(&self) -> bool

source

pub fn grow_to_fit(&mut self, b: &Range<T>)

source

pub fn contains_range(&self, val: &Range<T>) -> bool

Returns true if self contains the specified range.

source

pub fn intersects(&self, val: &Range<T>) -> bool

Returns true if two ranges intersect.

source§

impl<T: Copy + Sub<Output = T>> Range<T>

source

pub fn distance(&self) -> T

source§

impl<T: Copy + Sub<Output = T> + Add<Output = T>> Range<T>

source

pub fn grow(self, radius: T) -> Self

source§

impl<S> Range<S>

source

pub fn inner_as<B: 'static + Copy>(self) -> Range<B>where S: AsPrimitive<B>,

source

pub fn inner_into<A>(self) -> Range<A>where S: Into<A>,

source

pub fn inner_try_into<A>(self) -> Result<Range<A>, S::Error>where S: TryInto<A>,

source§

impl<T: Copy + Sub<Output = T> + Add<Output = T>> Range<T>

source

pub fn from_point(point: T, radius: T) -> Range<T>

Create a range from a point and radius.

source§

impl<T: Copy + Ord> Range<T>

source

pub fn get_intersection(&self, val: &Range<T>) -> Option<Range<T>>

Creates a range that represents the intersection range.

Trait Implementations§

source§

impl<T: Clone> Clone for Range<T>

source§

fn clone(&self) -> Range<T>

Returns a copy 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<T: Debug> Debug for Range<T>

source§

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

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

impl<T: Default> Default for Range<T>

source§

fn default() -> Range<T>

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

impl<B> From<[B; 2]> for Range<B>

source§

fn from(a: [B; 2]) -> Self

Converts to this type from the input type.
source§

impl<B> From<Range<B>> for [B; 2]

source§

fn from(a: Range<B>) -> Self

Converts to this type from the input type.
source§

impl<T: Hash> Hash for Range<T>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T: PartialEq> PartialEq<Range<T>> for Range<T>

source§

fn eq(&self, other: &Range<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: Copy> Copy for Range<T>

source§

impl<T: Eq> Eq for Range<T>

source§

impl<T> StructuralEq for Range<T>

source§

impl<T> StructuralPartialEq for Range<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for Range<T>where T: RefUnwindSafe,

§

impl<T> Send for Range<T>where T: Send,

§

impl<T> Sync for Range<T>where T: Sync,

§

impl<T> Unpin for Range<T>where T: Unpin,

§

impl<T> UnwindSafe for Range<T>where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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> ToOwned for Twhere T: Clone,

§

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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.