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 max<A: Into<Vec2>, B: Into<Vec2>>(a: A, b: B) -> Self
Returns a new Vec2 that is a maximum per coordinate.
fn min<A: Into<Vec2>, B: Into<Vec2>>(a: A, b: B) -> Self
Returns a new Vec2 that is no larger than any input in both dimensions.
fn or_min<T: Into<Vec2>>(self, other: T) -> Self
Returns the minimum of self and other.
fn or_max<T: Into<Vec2>>(self, other: T) -> Self
Returns the maximum of self and other.
fn keep_x(&self) -> Self
Returns a vector with the X component of self, and y=0.
fn keep_y(&self) -> Self
Returns a vector with the Y component of self, and x=0.
fn zero() -> Self
Alias for Vec2::new(0,0).
fn stack_vertical(&self, other: &Vec2) -> Vec2
Returns (max(self.x,other.x), self.y+other.y)
fn stack_horizontal(&self, other: &Vec2) -> Vec2
Returns (self.x+other.x, max(self.y,other.y))
fn fits_in<T: Into<Vec2>>(&self, other: T) -> bool
Returns true if self could fit inside other.
Shortcut for self.x <= other.x && self.y <= other.y.
fn with(&self, o: Orientation, value: usize) -> Self
Returns a new Vec2 with the axis o set to value.
impl<T> XY<T>[src]
fn new(x: T, y: T) -> Self
Creates a new XY from the given values.
fn map<U, F: Fn(T) -> U>(self, f: F) -> XY<U>
Creates a new XY by applying f to x and y.
fn pair(self) -> (T, T)
Destructure self into a pair.
fn as_ref(&self) -> XY<&T>
Return a XY with references to this one's values.
fn iter(&self) -> Chain<Once<&T>, Once<&T>>
Creates an iterator that returns references to x, then y.
fn get(&self, o: Orientation) -> &T
Returns a reference to the value on the given axis.
fn zip_map<U, V, F: Fn(T, U) -> V>(self, other: XY<U>, f: F) -> XY<V>
Returns a new XY by calling f on self and other for each axis.
impl<T> XY<Option<T>>[src]
impl XY<bool>[src]
fn any(&self) -> bool
Returns true if any of x or y is true.
fn both(&self) -> bool
Returns true if both x and y are true.
impl<T: Copy> XY<T>[src]
fn both_from(value: T) -> Self
Creates a XY with both x and y set to value.
Trait Implementations
impl PartialOrd for XY<usize>[src]
fn partial_cmp(&self, other: &Vec2) -> Option<Ordering>
a < b <=> a.x < b.x && a.y < b.y
fn lt(&self, other: &Rhs) -> bool1.0.0
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
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
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
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
impl From<(i32, i32)> for XY<usize>[src]
impl From<(u32, u32)> for XY<usize>[src]
impl<T: Into<Vec2>> Add<T> for XY<usize>[src]
type Output = Vec2
The resulting type after applying the + operator
fn add(self, other: T) -> Vec2
The method for the + operator
impl<T: Into<Vec2>> Sub<T> for XY<usize>[src]
type Output = Vec2
The resulting type after applying the - operator
fn sub(self, other: T) -> Vec2
The method for the - operator
impl Div<usize> for XY<usize>[src]
type Output = Vec2
The resulting type after applying the / operator
fn div(self, other: usize) -> Vec2
The method for the / operator
impl Mul<usize> for XY<usize>[src]
type Output = Vec2
The resulting type after applying the * operator
fn mul(self, other: usize) -> Vec2
The method for the * operator
impl<T: PartialEq> PartialEq for XY<T>[src]
fn eq(&self, __arg_0: &XY<T>) -> bool
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
This method tests for !=.
impl<T: Copy> Copy for XY<T>[src]
impl<T: Clone> Clone for XY<T>[src]
fn clone(&self) -> XY<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0
Performs copy-assignment from source. Read more