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]
impl XY<usize>
pub fn max_value() -> Self
[src]
pub fn max_value() -> Self
Returns a Vec2
with usize::max_value()
in each axis.
pub fn saturating_sub<O: Into<Self>>(&self, other: O) -> Self
[src]
pub fn saturating_sub<O: Into<Self>>(&self, other: O) -> Self
Saturating subtraction. Computes self - other
, saturating at 0.
Never panics.
pub fn saturating_add<O: Into<XY<isize>>>(&self, other: O) -> Self
[src]
pub fn saturating_add<O: Into<XY<isize>>>(&self, other: O) -> Self
Saturating addition with a signed vec.
Any coordinates saturates to 0.
pub fn div_up<O>(&self, other: O) -> Self where
O: Into<Self>,
[src]
pub fn div_up<O>(&self, other: O) -> Self where
O: Into<Self>,
Term-by-term integer division that rounds up.
pub fn checked_sub<O: Into<Self>>(&self, other: O) -> Option<Self>
[src]
pub fn checked_sub<O: Into<Self>>(&self, other: O) -> Option<Self>
Checked subtraction. Computes self - other
if possible.
Returns None
if self.x < other.x || self.y < other.y
.
Never panics.
pub fn signed(self) -> XY<isize>
[src]
pub fn signed(self) -> XY<isize>
Returns a XY<isize>
from self
.
impl<T: Ord> XY<T>
[src]
impl<T: Ord> XY<T>
pub fn fits_in<O: Into<Self>>(&self, other: O) -> bool
[src]
pub fn fits_in<O: Into<Self>>(&self, other: O) -> bool
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.
pub fn fits<O: Into<Self>>(&self, other: O) -> bool
[src]
pub fn fits<O: Into<Self>>(&self, other: O) -> bool
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.
pub fn max<A: Into<XY<T>>, B: Into<XY<T>>>(a: A, b: B) -> Self
[src]
pub fn max<A: Into<XY<T>>, B: Into<XY<T>>>(a: A, b: B) -> Self
Returns a new Vec2 that is a maximum per coordinate.
pub fn min<A: Into<XY<T>>, B: Into<XY<T>>>(a: A, b: B) -> Self
[src]
pub fn min<A: Into<XY<T>>, B: Into<XY<T>>>(a: A, b: B) -> Self
Returns a new Vec2 that is no larger than any input in both dimensions.
pub fn or_min<O: Into<XY<T>>>(self, other: O) -> Self
[src]
pub fn or_min<O: Into<XY<T>>>(self, other: O) -> Self
Returns the minimum of self
and other
.
pub fn or_max<O: Into<XY<T>>>(self, other: O) -> Self
[src]
pub fn or_max<O: Into<XY<T>>>(self, other: O) -> Self
Returns the maximum of self
and other
.
impl<T: Ord + Add<Output = T> + Clone> XY<T>
[src]
impl<T: Ord + Add<Output = T> + Clone> XY<T>
pub fn stack_vertical(&self, other: &Self) -> Self
[src]
pub fn stack_vertical(&self, other: &Self) -> Self
Returns (max(self.x,other.x), self.y+other.y)
pub fn stack_horizontal(&self, other: &Self) -> Self
[src]
pub fn stack_horizontal(&self, other: &Self) -> Self
Returns (self.x+other.x, max(self.y,other.y))
pub fn fits_in_rect<O1, O2>(&self, top_left: O1, size: O2) -> bool where
O1: Into<Self>,
O2: Into<Self>,
[src]
pub fn fits_in_rect<O1, O2>(&self, top_left: O1, size: O2) -> bool where
O1: Into<Self>,
O2: Into<Self>,
Returns true
if self
fits in the given rectangle.
impl<T: Zero + Clone> XY<T>
[src]
impl<T: Zero + Clone> XY<T>
pub fn keep_x(&self) -> Self
[src]
pub fn keep_x(&self) -> Self
Returns a vector with the X component of self, and y=0.
pub fn keep_y(&self) -> Self
[src]
pub fn keep_y(&self) -> Self
Returns a vector with the Y component of self, and x=0.
pub fn zero() -> Self
[src]
pub fn zero() -> Self
Alias for Self::new(0,0)
.
impl<T> XY<T>
[src]
impl<T> XY<T>
pub fn new(x: T, y: T) -> Self
[src]
pub fn new(x: T, y: T) -> Self
Creates a new XY
from the given values.
pub fn swap(self) -> Self
[src]
pub fn swap(self) -> Self
Swaps the x and y values.
pub fn fold<U, F>(self, f: F) -> U where
F: FnOnce(T, T) -> U,
[src]
pub fn fold<U, F>(self, f: F) -> U where
F: FnOnce(T, T) -> U,
Returns f(self.x, self.y)
pub fn map<U, F>(self, f: F) -> XY<U> where
F: Fn(T) -> U,
[src]
pub fn map<U, F>(self, f: F) -> XY<U> where
F: Fn(T) -> U,
Creates a new XY
by applying f
to x
and y
.
pub fn map_if<F>(self, condition: XY<bool>, f: F) -> Self where
F: Fn(T) -> T,
[src]
pub fn map_if<F>(self, condition: XY<bool>, f: F) -> Self where
F: Fn(T) -> T,
Applies f
on axis where condition
is true.
Carries over self
otherwise.
pub fn run_if<F, U>(self, condition: XY<bool>, f: F) -> XY<Option<U>> where
F: Fn(T) -> U,
[src]
pub fn run_if<F, U>(self, condition: XY<bool>, f: F) -> XY<Option<U>> where
F: Fn(T) -> U,
Applies f
on axis where condition
is true.
Returns None
otherwise.
pub fn map_x<F>(self, f: F) -> Self where
F: FnOnce(T) -> T,
[src]
pub fn map_x<F>(self, f: F) -> Self where
F: FnOnce(T) -> T,
Creates a new XY
by applying f
to x
, and carrying y
over.
pub fn map_y<F>(self, f: F) -> Self where
F: FnOnce(T) -> T,
[src]
pub fn map_y<F>(self, f: F) -> Self where
F: FnOnce(T) -> T,
Creates a new XY
by applying f
to y
, and carrying x
over.
pub fn pair(self) -> (T, T)
[src]
pub fn pair(self) -> (T, T)
Destructure self into a pair.
pub fn as_ref(&self) -> XY<&T>
[src]
pub fn as_ref(&self) -> XY<&T>
Return a XY
with references to this one's values.
ⓘImportant traits for Chain<A, B>pub fn iter(&self) -> Chain<Once<&T>, Once<&T>>
[src]
pub fn iter(&self) -> Chain<Once<&T>, Once<&T>>
Creates an iterator that returns references to x
, then y
.
ⓘImportant traits for &'a mut Rpub fn get(&self, o: Orientation) -> &T
[src]
pub fn get(&self, o: Orientation) -> &T
Returns a reference to the value on the given axis.
ⓘImportant traits for &'a mut Rpub fn get_mut(&mut self, o: Orientation) -> &mut T
[src]
pub fn get_mut(&mut self, o: Orientation) -> &mut T
Returns a mutable reference to the value on the given axis.
pub fn zip<U>(self, other: XY<U>) -> XY<(T, U)>
[src]
pub fn zip<U>(self, other: XY<U>) -> XY<(T, U)>
Returns a new XY
of tuples made by zipping self
and other
.
pub fn zip3<U, V>(self, a: XY<U>, b: XY<V>) -> XY<(T, U, V)>
[src]
pub fn zip3<U, V>(self, a: XY<U>, b: XY<V>) -> XY<(T, U, V)>
Returns a new XY
of tuples made by zipping self
, a
and b
.
pub fn zip4<U, V, W>(self, a: XY<U>, b: XY<V>, c: XY<W>) -> XY<(T, U, V, W)>
[src]
pub fn zip4<U, V, W>(self, a: XY<U>, b: XY<V>, c: XY<W>) -> XY<(T, U, V, W)>
Returns a new XY
of tuples made by zipping self
, a
, b
and c
.
pub fn zip5<U, V, W, Z>(
self,
a: XY<U>,
b: XY<V>,
c: XY<W>,
d: XY<Z>
) -> XY<(T, U, V, W, Z)>
[src]
pub fn zip5<U, V, W, Z>(
self,
a: XY<U>,
b: XY<V>,
c: XY<W>,
d: XY<Z>
) -> XY<(T, U, V, W, Z)>
Returns a new XY
of tuples made by zipping self
, a
, b
, c
and d
.
pub fn zip_map<U, V, F>(self, other: XY<U>, f: F) -> XY<V> where
F: Fn(T, U) -> V,
[src]
pub fn zip_map<U, V, F>(self, other: XY<U>, f: F) -> XY<V> where
F: Fn(T, U) -> V,
Returns a new XY
by calling f
on self
and other
for each axis.
pub fn keep(self, keep: XY<bool>) -> XY<Option<T>>
[src]
pub fn keep(self, keep: XY<bool>) -> XY<Option<T>>
For each axis, keep the element from self
if keep
is true
.
impl<T: Clone> XY<T>
[src]
impl<T: Clone> XY<T>
pub fn with_axis(&self, o: Orientation, value: T) -> Self
[src]
pub fn with_axis(&self, o: Orientation, value: T) -> Self
Returns a new XY
with the axis o
set to value
.
pub fn with_axis_from(&self, o: Orientation, other: &Self) -> Self
[src]
pub fn with_axis_from(&self, o: Orientation, other: &Self) -> Self
Returns a new XY
with the axis o
set to the value from other
.
pub fn set_axis_from(&mut self, o: Orientation, other: &Self)
[src]
pub fn set_axis_from(&mut self, o: Orientation, other: &Self)
Sets the axis o
on self
to the value from other
.
impl<T> XY<Option<T>>
[src]
impl<T> XY<Option<T>>
pub fn unwrap_or(self, other: XY<T>) -> XY<T>
[src]
pub fn unwrap_or(self, other: XY<T>) -> XY<T>
Returns a new XY
by calling unwrap_or
on each axis.
impl XY<bool>
[src]
impl XY<bool>
pub fn any(self) -> bool
[src]
pub fn any(self) -> bool
Returns true
if any of x
or y
is true
.
pub fn both(self) -> bool
[src]
pub fn both(self) -> bool
Returns true
if both x
and y
are true
.
pub fn select<T>(self, other: XY<T>) -> XY<Option<T>>
[src]
pub fn select<T>(self, other: XY<T>) -> XY<Option<T>>
For each axis, keeps elements from other
if self
is true
.
pub fn select_or<T>(self, if_true: XY<T>, if_false: XY<T>) -> XY<T>
[src]
pub fn select_or<T>(self, if_true: XY<T>, if_false: XY<T>) -> XY<T>
For each axis, selects if_true
if self
is true, else if_false
.
pub fn and(self, other: Self) -> Self
[src]
pub fn and(self, other: Self) -> Self
Returns a term-by-term AND operation.
pub fn or(self, other: Self) -> Self
[src]
pub fn or(self, other: Self) -> Self
Returns a term-by-term OR operation.
impl<T: Copy> XY<T>
[src]
impl<T: Copy> XY<T>
Trait Implementations
impl<T: PartialOrd> PartialOrd for XY<T>
[src]
impl<T: PartialOrd> PartialOrd for XY<T>
fn partial_cmp(&self, other: &XY<T>) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &XY<T>) -> Option<Ordering>
a < b
<=> a.x < b.x && a.y < b.y
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
fn le(&self, other: &Rhs) -> bool
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) -> bool
1.0.0[src]
fn gt(&self, other: &Rhs) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
fn ge(&self, other: &Rhs) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<'a, T> From<&'a XY<T>> for XY<T> where
T: Clone,
[src]
impl<'a, T> From<&'a XY<T>> for XY<T> where
T: Clone,
impl<T> From<T> for XY<isize> where
T: Into<XY<usize>>,
[src]
impl<T> From<T> for XY<isize> where
T: Into<XY<usize>>,
impl From<(i32, i32)> for XY<usize>
[src]
impl From<(i32, i32)> for XY<usize>
impl From<(u32, u32)> for XY<usize>
[src]
impl From<(u32, u32)> for XY<usize>
impl From<(u8, u8)> for XY<usize>
[src]
impl From<(u8, u8)> for XY<usize>
impl From<(u16, u16)> for XY<usize>
[src]
impl From<(u16, u16)> for XY<usize>
impl<T, O> Add<O> for XY<T> where
T: Add<Output = T>,
O: Into<XY<T>>,
[src]
impl<T, O> Add<O> for XY<T> where
T: Add<Output = T>,
O: Into<XY<T>>,
type Output = Self
The resulting type after applying the +
operator.
fn add(self, other: O) -> Self
[src]
fn add(self, other: O) -> Self
Performs the +
operation.
impl<T, O> Sub<O> for XY<T> where
T: Sub<Output = T>,
O: Into<XY<T>>,
[src]
impl<T, O> Sub<O> for XY<T> where
T: Sub<Output = T>,
O: Into<XY<T>>,
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, other: O) -> Self
[src]
fn sub(self, other: O) -> Self
Performs the -
operation.
impl<T: Clone + Div<Output = T>> Div<T> for XY<T>
[src]
impl<T: Clone + Div<Output = T>> Div<T> for XY<T>
type Output = Self
The resulting type after applying the /
operator.
fn div(self, other: T) -> Self
[src]
fn div(self, other: T) -> Self
Performs the /
operation.
impl Mul<usize> for XY<usize>
[src]
impl Mul<usize> for XY<usize>
type Output = Vec2
The resulting type after applying the *
operator.
fn mul(self, other: usize) -> Vec2
[src]
fn mul(self, other: usize) -> Vec2
Performs the *
operation.
impl<T> Mul<XY<T>> for XY<T> where
T: Mul<T>,
[src]
impl<T> Mul<XY<T>> for XY<T> where
T: Mul<T>,
type Output = XY<T::Output>
The resulting type after applying the *
operator.
fn mul(self, other: XY<T>) -> Self::Output
[src]
fn mul(self, other: XY<T>) -> Self::Output
Performs the *
operation.
impl<T> Div<XY<T>> for XY<T> where
T: Div<T>,
[src]
impl<T> Div<XY<T>> for XY<T> where
T: Div<T>,
type Output = XY<T::Output>
The resulting type after applying the /
operator.
fn div(self, other: XY<T>) -> Self::Output
[src]
fn div(self, other: XY<T>) -> Self::Output
Performs the /
operation.
impl<T: Debug> Debug for XY<T>
[src]
impl<T: Debug> Debug for XY<T>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<T: Clone> Clone for XY<T>
[src]
impl<T: Clone> Clone for XY<T>
fn clone(&self) -> 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[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<T: Copy> Copy for XY<T>
[src]
impl<T: Copy> Copy for XY<T>
impl<T: PartialEq> PartialEq for XY<T>
[src]
impl<T: PartialEq> PartialEq for XY<T>
fn eq(&self, other: &XY<T>) -> bool
[src]
fn eq(&self, other: &XY<T>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &XY<T>) -> bool
[src]
fn ne(&self, other: &XY<T>) -> bool
This method tests for !=
.
impl<T: Eq> Eq for XY<T>
[src]
impl<T: Eq> Eq for XY<T>
impl<T: Hash> Hash for XY<T>
[src]
impl<T: Hash> Hash for XY<T>
fn hash<__HT: Hasher>(&self, state: &mut __HT)
[src]
fn hash<__HT: Hasher>(&self, state: &mut __HT)
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]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<T> IntoIterator for XY<T>
[src]
impl<T> IntoIterator for XY<T>
type Item = T
The type of the elements being iterated over.
type IntoIter = Chain<Once<T>, Once<T>>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more
impl<T> From<(T, T)> for XY<T>
[src]
impl<T> From<(T, T)> for XY<T>
impl<T, U> From<(XY<T>, XY<U>)> for XY<(T, U)>
[src]
impl<T, U> From<(XY<T>, XY<U>)> for XY<(T, U)>