Struct unsegen::base::basic_types::AxisDiff [−][src]
pub struct AxisDiff<T: AxisDimension> { /* fields omitted */ }
Expand description
AxisDiff (the base for ColDiff or RowDiff) specifies a difference between two coordinate points on a terminal grid. (i.e., a coordinate of a vector on the terminal cell grid)
Implementations
impl<T: AxisDimension> AxisDiff<T>
[src]
impl<T: AxisDimension> AxisDiff<T>
[src]pub fn from_origin(self) -> AxisIndex<T>
[src]
pub fn from_origin(self) -> AxisIndex<T>
[src]Calculate the AxisIndex that has the specified AxisDiff to the origin (i.e., 0). Technically this just converts an AxisIndex into an AxisDiff, but is semantically more explicit.
Examples:
use unsegen::base::{ColIndex, ColDiff}; assert_eq!(ColDiff::new(27).from_origin(), ColIndex::new(27));
pub fn try_into_positive(self) -> Result<PositiveAxisDiff<T>, Self>
[src]
pub fn try_into_positive(self) -> Result<PositiveAxisDiff<T>, Self>
[src]Try to convert the current value into a PositiveAxisDiff. If the conversion fails, the original value is returned.
Examples:
use unsegen::base::{ColDiff, Width}; assert_eq!(ColDiff::new(27).try_into_positive(), Ok(Width::new(27).unwrap())); assert_eq!(ColDiff::new(0).try_into_positive(), Ok(Width::new(0).unwrap())); assert_eq!(ColDiff::new(-37).try_into_positive(), Err(ColDiff::new(-37)));
pub fn abs(self) -> PositiveAxisDiff<T>
[src]
pub fn abs(self) -> PositiveAxisDiff<T>
[src]Convert the current value into a PositiveAxisDiff by taking the absolute value of the axis difference.
Examples:
use unsegen::base::{ColDiff, Width}; assert_eq!(ColDiff::new(27).abs(), Width::new(27).unwrap()); assert_eq!(ColDiff::new(0).abs(), Width::new(0).unwrap()); assert_eq!(ColDiff::new(-37).abs(), Width::new(37).unwrap());
pub fn positive_or_zero(self) -> PositiveAxisDiff<T>
[src]
pub fn positive_or_zero(self) -> PositiveAxisDiff<T>
[src]Clamp the value into a positive or zero range
Examples:
use unsegen::base::ColDiff; assert_eq!(ColDiff::new(27).positive_or_zero(), ColDiff::new(27)); assert_eq!(ColDiff::new(0).positive_or_zero(), ColDiff::new(0)); assert_eq!(ColDiff::new(-37).positive_or_zero(), ColDiff::new(0));
Trait Implementations
impl<T: AxisDimension, I: Into<AxisDiff<T>>> AddAssign<I> for AxisDiff<T>
[src]
impl<T: AxisDimension, I: Into<AxisDiff<T>>> AddAssign<I> for AxisDiff<T>
[src]fn add_assign(&mut self, rhs: I)
[src]
fn add_assign(&mut self, rhs: I)
[src]Performs the +=
operation. Read more
impl<T: Clone + AxisDimension> Clone for AxisDiff<T>
[src]
impl<T: Clone + AxisDimension> Clone for AxisDiff<T>
[src]impl<T: Debug + AxisDimension> Debug for AxisDiff<T>
[src]
impl<T: Debug + AxisDimension> Debug for AxisDiff<T>
[src]impl<T: AxisDimension> Div<i32> for AxisDiff<T>
[src]
impl<T: AxisDimension> Div<i32> for AxisDiff<T>
[src]impl<T: AxisDimension> From<i32> for AxisDiff<T>
[src]
impl<T: AxisDimension> From<i32> for AxisDiff<T>
[src]impl<T: AxisDimension> Into<AxisDiff<T>> for PositiveAxisDiff<T>
[src]
impl<T: AxisDimension> Into<AxisDiff<T>> for PositiveAxisDiff<T>
[src]impl<T: AxisDimension> Into<i32> for AxisDiff<T>
[src]
impl<T: AxisDimension> Into<i32> for AxisDiff<T>
[src]impl<T: AxisDimension> Mul<i32> for AxisDiff<T>
[src]
impl<T: AxisDimension> Mul<i32> for AxisDiff<T>
[src]impl<T: AxisDimension> Neg for AxisDiff<T>
[src]
impl<T: AxisDimension> Neg for AxisDiff<T>
[src]impl<T: Ord + AxisDimension> Ord for AxisDiff<T>
[src]
impl<T: Ord + AxisDimension> Ord for AxisDiff<T>
[src]impl<T: AxisDimension, I: Into<AxisDiff<T>> + Copy> PartialOrd<I> for AxisDiff<T>
[src]
impl<T: AxisDimension, I: Into<AxisDiff<T>> + Copy> PartialOrd<I> for AxisDiff<T>
[src]fn partial_cmp(&self, other: &I) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &I) -> Option<Ordering>
[src]This method returns an ordering between self
and other
values if one exists. Read more
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than (for self
and other
) and is used by the <
operator. Read more
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl<T: AxisDimension, I: Into<AxisDiff<T>>> SubAssign<I> for AxisDiff<T>
[src]
impl<T: AxisDimension, I: Into<AxisDiff<T>>> SubAssign<I> for AxisDiff<T>
[src]fn sub_assign(&mut self, rhs: I)
[src]
fn sub_assign(&mut self, rhs: I)
[src]Performs the -=
operation. Read more
impl<'a, T: 'a + AxisDimension + PartialOrd + Ord> Sum<&'a AxisDiff<T>> for AxisDiff<T>
[src]
impl<'a, T: 'a + AxisDimension + PartialOrd + Ord> Sum<&'a AxisDiff<T>> for AxisDiff<T>
[src]impl<T: AxisDimension + PartialOrd + Ord> Sum<AxisDiff<T>> for AxisDiff<T>
[src]
impl<T: AxisDimension + PartialOrd + Ord> Sum<AxisDiff<T>> for AxisDiff<T>
[src]impl<T: Copy + AxisDimension> Copy for AxisDiff<T>
[src]
impl<T: Eq + AxisDimension> Eq for AxisDiff<T>
[src]
impl<T: AxisDimension> StructuralEq for AxisDiff<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for AxisDiff<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for AxisDiff<T> where
T: Send,
T: Send,
impl<T> Sync for AxisDiff<T> where
T: Sync,
T: Sync,
impl<T> Unpin for AxisDiff<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for AxisDiff<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T, Rhs, Output> NumOps<Rhs, Output> for T where
T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,
[src]
T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,