Struct cursive::XY
[−]
[src]
pub struct XY<T> {
pub x: T,
pub y: T,
}A generic structure with a value for each axis.
Fields
x: T
X-axis value
y: T
Y-axis value
Methods
impl XY<usize>[src]
fn saturating_sub<O: Into<Self>>(&self, other: O) -> Self[src]
Saturating subtraction. Computes self - other, saturating at 0.
Never panics.
fn checked_sub<O: Into<Self>>(&self, other: O) -> Option<Self>[src]
Checked subtraction. Computes self - other if possible.
Returns None if self.x < other.x || self.y < other.y.
Never panics.
fn signed(self) -> XY<isize>[src]
Returns a XY<isize> from self.
impl<T: Ord> XY<T>[src]
fn fits_in<O: Into<Self>>(&self, other: O) -> bool[src]
Returns true if self could fit inside other.
Shortcut for self.x <= other.x && self.y <= other.y.
If this returns true, then other - self will not underflow.
fn fits<O: Into<Self>>(&self, other: O) -> bool[src]
Returns true if other could fit inside self.
Shortcut for self.x >= other.x && self.y >= other.y.
If this returns true, then self - other will not underflow.
fn max<A: Into<XY<T>>, B: Into<XY<T>>>(a: A, b: B) -> Self[src]
Returns a new Vec2 that is a maximum per coordinate.
fn min<A: Into<XY<T>>, B: Into<XY<T>>>(a: A, b: B) -> Self[src]
Returns a new Vec2 that is no larger than any input in both dimensions.
fn or_min<O: Into<XY<T>>>(self, other: O) -> Self[src]
Returns the minimum of self and other.
fn or_max<O: Into<XY<T>>>(self, other: O) -> Self[src]
Returns the maximum of self and other.
impl<T: Ord + Add<Output = T> + Clone> XY<T>[src]
fn stack_vertical(&self, other: &Self) -> Self[src]
Returns (max(self.x,other.x), self.y+other.y)
fn stack_horizontal(&self, other: &Self) -> Self[src]
Returns (self.x+other.x, max(self.y,other.y))
fn fits_in_rect<O1, O2>(&self, top_left: O1, size: O2) -> bool where
O1: Into<Self>,
O2: Into<Self>, [src]
O1: Into<Self>,
O2: Into<Self>,
Returns true if self fits in the given rectangle.
impl<T: Zero + Clone> XY<T>[src]
fn keep_x(&self) -> Self[src]
Returns a vector with the X component of self, and y=0.
fn keep_y(&self) -> Self[src]
Returns a vector with the Y component of self, and x=0.
fn zero() -> Self[src]
Alias for Self::new(0,0).
impl<T> XY<T>[src]
fn new(x: T, y: T) -> Self[src]
Creates a new XY from the given values.
fn map<U, F: Fn(T) -> U>(self, f: F) -> XY<U>[src]
Creates a new XY by applying f to x and y.
fn map_x<F: Fn(T) -> T>(self, f: F) -> Self[src]
Creates a new XY by applying f to x, and carrying y over.
fn map_y<F: Fn(T) -> T>(self, f: F) -> Self[src]
Creates a new XY by applying f to y, and carrying x over.
fn pair(self) -> (T, T)[src]
Destructure self into a pair.
fn as_ref(&self) -> XY<&T>[src]
Return a XY with references to this one's values.
fn iter(&self) -> Chain<Once<&T>, Once<&T>>[src]
Creates an iterator that returns references to x, then y.
fn get(&self, o: Orientation) -> &T[src]
Returns a reference to the value on the given axis.
fn get_mut(&mut self, o: Orientation) -> &mut T[src]
Returns a mutable reference to the value on the given axis.
fn zip<U>(self, other: XY<U>) -> XY<(T, U)>[src]
Returns a new XY of tuples made by zipping self and other.
fn zip_map<U, V, F: Fn(T, U) -> V>(self, other: XY<U>, f: F) -> XY<V>[src]
Returns a new XY by calling f on self and other for each axis.
impl<T: Clone> XY<T>[src]
fn with_axis(&self, o: Orientation, value: T) -> Self[src]
Returns a new XY with the axis o set to value.
fn with_axis_from(&self, o: Orientation, other: &Self) -> Self[src]
Returns a new XY with the axis o set to the value from other.
fn set_axis_from(&mut self, o: Orientation, other: &Self)[src]
Sets the axis o on self to the value from other.
impl<T> XY<Option<T>>[src]
impl XY<bool>[src]
fn any(&self) -> bool[src]
Returns true if any of x or y is true.
fn both(&self) -> bool[src]
Returns true if both x and y are true.
impl<T: Copy> XY<T>[src]
Trait Implementations
impl<T: PartialOrd> PartialOrd for XY<T>[src]
fn partial_cmp(&self, other: &XY<T>) -> Option<Ordering>[src]
a < b <=> a.x < b.x && a.y < b.y
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
This method tests less than (for self and other) and is used by the < operator. Read more
fn le(&self, other: &Rhs) -> bool1.0.0[src]
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
This method tests greater than (for self and other) and is used by the > operator. Read more
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
impl<T: Into<XY<usize>>> From<T> for XY<isize>[src]
impl From<(i32, i32)> for XY<usize>[src]
impl From<(u32, u32)> for XY<usize>[src]
impl From<(u8, u8)> for XY<usize>[src]
impl From<(u16, u16)> for XY<usize>[src]
impl<T: Add<Output = T>, O: Into<XY<T>>> Add<O> for XY<T>[src]
type Output = Self
The resulting type after applying the + operator.
fn add(self, other: O) -> Self[src]
Performs the + operation.
impl<T: Sub<Output = T>, O: Into<XY<T>>> Sub<O> for XY<T>[src]
type Output = Self
The resulting type after applying the - operator.
fn sub(self, other: O) -> Self[src]
Performs the - operation.
impl<T: Clone + Div<Output = T>> Div<T> for XY<T>[src]
type Output = Self
The resulting type after applying the / operator.
fn div(self, other: T) -> Self[src]
Performs the / operation.
impl Mul<usize> for XY<usize>[src]
type Output = Vec2
The resulting type after applying the * operator.
fn mul(self, other: usize) -> Vec2[src]
Performs the * operation.
impl<T: Debug> Debug for XY<T>[src]
impl<T: Clone> Clone for XY<T>[src]
fn clone(&self) -> XY<T>[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
impl<T: Copy> Copy for XY<T>[src]
impl<T: PartialEq> PartialEq for XY<T>[src]
fn eq(&self, __arg_0: &XY<T>) -> bool[src]
This method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, __arg_0: &XY<T>) -> bool[src]
This method tests for !=.
impl<T: Eq> Eq for XY<T>[src]
impl<T: Hash> Hash for XY<T>[src]
fn hash<__HT: Hasher>(&self, __arg_0: &mut __HT)[src]
Feeds this value into the given [Hasher]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher]. Read more