Struct XY

Source
pub struct XY<T> {
    pub x: T,
    pub y: T,
}
Expand description

A generic structure with a value for each axis.

Fields§

§x: T

X-axis value

§y: T

Y-axis value

Implementations§

Source§

impl XY<Offset>

Source

pub fn center() -> XY<Offset>

Returns a position centered on both axis.

Source

pub fn absolute<T>(offset: T) -> XY<Offset>
where T: Into<XY<usize>>,

Returns a position absolute on both axis.

Source

pub fn parent<T>(offset: T) -> XY<Offset>
where T: Into<XY<isize>>,

Returns a position relative to the parent on both axis.

Source

pub fn compute_offset<S, A, P>( &self, size: S, available: A, parent: P, ) -> XY<usize>
where S: Into<XY<usize>>, A: Into<XY<usize>>, P: Into<XY<usize>>,

Computes the offset required to draw a view.

When drawing a view with size in a container with available, and a parent with the absolute coordinates parent, drawing the child with its top-left corner at the returned coordinates will position him appropriately.

Source§

impl XY<f32>

Source

pub fn rotated(self, angle_rad: f32) -> XY<f32>

Returns the given vector, rotated by an angle in radians.

Source§

impl XY<usize>

Source

pub const MAX: XY<usize>

A Vec2 with usize::MAX in each axis.

Source

pub const ZERO: XY<usize>

The origin, { x: 0, y: 0 }.

Source

pub const X: XY<usize>

The unit X vector { x: 1, y: 0 }.

Source

pub const Y: XY<usize>

The unit Y vector { x: 0, y: 1 }.

Source

pub const fn max_value() -> XY<usize>

Returns a Vec2 with usize::MAX in each axis.

§Examples
assert!(Vec2::new(9999, 9999) < Vec2::max_value());
Source

pub fn saturating_sub<O>(&self, other: O) -> XY<usize>
where O: Into<XY<usize>>,

Saturating subtraction. Computes self - other, saturating at 0.

Never panics.

§Examples
let u = Vec2::new(1, 2);
let v = Vec2::new(2, 1);
assert_eq!(u.saturating_sub(v), Vec2::new(0, 1));
Source

pub fn saturating_add<O>(&self, other: O) -> XY<usize>
where O: Into<XY<isize>>,

Saturating addition with a signed vec.

Any coordinates saturates to 0.

§Examples
let u = Vec2::new(1, 2);
let v = XY::<isize>::new(-2, 1);
assert_eq!(u.saturating_add(v), Vec2::new(0, 3));
Source

pub fn checked_add<O>(&self, other: O) -> Option<XY<usize>>
where O: Into<XY<isize>>,

Checked addition with a signed vec.

Will return None if any coordinates exceeds bounds.

Source

pub fn div_up<O>(&self, other: O) -> XY<usize>
where O: Into<XY<usize>>,

Term-by-term integer division that rounds up.

§Examples
let u = Vec2::new(1, 6);
let v = Vec2::new(2, 3);
assert_eq!(u.div_up(v), Vec2::new(1, 2));
Source

pub fn checked_sub<O>(&self, other: O) -> Option<XY<usize>>
where O: Into<XY<usize>>,

Checked subtraction. Computes self - other if possible.

Returns None if self.x < other.x || self.y < other.y.

Never panics.

§Examples
let xy = Vec2::new(1, 2);
assert_eq!(xy.checked_sub((1, 1)), Some(Vec2::new(0, 1)));
assert_eq!(xy.checked_sub((2, 2)), None);
Source

pub const fn signed(self) -> XY<isize>

Returns a XY<isize> from self.

§Examples
let v: XY<isize> = Vec2::new(1, 2).signed().map(|i| i - 5);
assert_eq!(v, XY::new(-4, -3));

let u = Vec2::new(3, 4);
assert_eq!(u.saturating_add(v), Vec2::new(0, 1));
Source

pub fn sq_distance(a: XY<usize>, b: XY<usize>) -> usize

Returns the square distance between a and b.

Source§

impl<T> XY<T>
where T: Mul<Output = T> + Sub<Output = T> + Add<Output = T> + Copy,

Source

pub fn sq_norm(self) -> T

Returns the square distance between a and b.

Source§

impl<T> XY<T>
where T: Ord,

Source

pub fn fits_in<O>(&self, other: O) -> bool
where O: Into<XY<T>>,

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.

§Examples
let v = Vec2::new(1, 2);
assert!(v.fits_in((1, 2)));
assert!(v.fits_in((3, 3)));
assert!(!v.fits_in((2, 1)));
Source

pub fn fits<O>(&self, other: O) -> bool
where O: Into<XY<T>>,

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.

§Examples
let v = Vec2::new(1, 2);
assert!(v.fits((1, 2)));
assert!(v.fits((0, 0)));
assert!(!v.fits((2, 1)));
Source

pub fn strictly_lt<O>(&self, other: O) -> bool
where O: Into<XY<T>>,

Returns true if other is strictly less than self in each axis.

Source

pub fn strictly_gt<O>(&self, other: O) -> bool
where O: Into<XY<T>>,

Returns true if other is strictly greater than self in each axis.

Source

pub fn max<A, B>(a: A, b: B) -> XY<T>
where A: Into<XY<T>>, B: Into<XY<T>>,

Returns a new Vec2 that is a maximum per coordinate.

§Examples
assert_eq!(Vec2::max((1, 2), (3, 1)), Vec2::new(3, 2));
Source

pub fn min<A, B>(a: A, b: B) -> XY<T>
where A: Into<XY<T>>, B: Into<XY<T>>,

Returns a new Vec2 that is no larger than any input in both dimensions.

§Examples
assert_eq!(Vec2::min((1, 2), (3, 1)), Vec2::new(1, 1));
Source

pub fn or_min<O>(self, other: O) -> XY<T>
where O: Into<XY<T>>,

Returns the minimum of self and other.

This is equivalent to Vec2::min(self, other).

Source

pub fn or_max<O>(self, other: O) -> XY<T>
where O: Into<XY<T>>,

Returns the maximum of self and other.

This is equivalent to Vec2::max(self, other).

Source§

impl<T> XY<T>
where T: Ord + Add<Output = T> + Clone,

Source

pub fn stack_vertical(&self, other: &XY<T>) -> XY<T>

Returns (max(self.x,other.x), self.y+other.y)

Source

pub fn stack_horizontal(&self, other: &XY<T>) -> XY<T>

Returns (self.x+other.x, max(self.y,other.y))

Source

pub fn fits_in_rect<O1, O2>(&self, top_left: O1, size: O2) -> bool
where O1: Into<XY<T>>, O2: Into<XY<T>>,

Returns true if self fits in the given rectangle.

Source§

impl<T> XY<T>
where T: Add,

Source

pub fn sum(self) -> <T as Add>::Output

Returns self.x + self.y.

Source§

impl<T> XY<T>
where T: Mul,

Source

pub fn product(self) -> <T as Mul>::Output

Returns self.x * self.y

Source§

impl<T> XY<T>
where T: Zero + Clone,

Source

pub fn keep_x(&self) -> XY<T>

Returns a vector with the X component of self, and y=0.

§Examples
let xy = XY::new(1, 2);
assert_eq!(xy.keep_x(), XY::new(1, 0));
Source

pub fn keep_y(&self) -> XY<T>

Returns a vector with the Y component of self, and x=0.

§Examples
let xy = XY::new(1, 2);
assert_eq!(xy.keep_y(), XY::new(0, 2));
Source§

impl<T> XY<T>
where T: Zero,

Source

pub fn zero() -> XY<T>

Alias for Self::new(0,0).

§Examples
assert_eq!(Vec2::zero(), Vec2::new(0, 0));
Source§

impl<T> XY<T>

Source

pub const fn new(x: T, y: T) -> XY<T>

Creates a new XY from the given values.

Source

pub const fn from_major_minor( orientation: Orientation, major: T, minor: T, ) -> XY<T>

Creates a new XY from a the major and minor components of an orientation.

  • For Orientation::Horizontal, major is X and minor is Y.
  • For Orientation::Vertical, major is Y and minor is X.
Source

pub fn swap(self) -> XY<T>

Swaps the x and y values.

§Examples
let xy = XY::new(1, 2);
assert_eq!(xy.swap(), XY::new(2, 1));
Source

pub fn fold<U, F>(self, f: F) -> U
where F: FnOnce(T, T) -> U,

Returns f(self.x, self.y)

§Examples
let xy = XY::new(1, 2);

assert_eq!(xy.fold(std::ops::Add::add), 3);
assert_eq!(xy.fold(std::ops::Mul::mul), 2);
assert_eq!(xy.fold(|x, y| x < y), true);
Source

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.

§Examples
let xy = XY::new(1, 2);

assert_eq!(xy.map(|v| v * 2), XY::new(2, 4));
assert_eq!(xy.map(|v| v > 1), XY::new(false, true));
Source

pub fn map_if<F>(self, condition: XY<bool>, f: F) -> XY<T>
where F: Fn(T) -> T,

Applies f on axis where condition is true.

Carries over self otherwise.

§Examples
let xy = XY::new(1, 2);
let cond = XY::new(true, false);

assert_eq!(xy.map_if(cond, |v| v * 3), XY::new(3, 2));
Source

pub fn run_if<F, U>(self, condition: XY<bool>, f: F) -> XY<Option<U>>
where F: FnMut(T) -> U,

Applies f on axis where condition is true.

Returns None otherwise.

§Examples
let xy = XY::new(1, 2);
let cond = XY::new(true, false);

assert_eq!(xy.run_if(cond, |v| v * 3), XY::new(Some(3), None));
Source

pub fn map_x<F>(self, f: F) -> XY<T>
where F: FnOnce(T) -> T,

Creates a new XY by applying f to x, and carrying y over.

§Examples
let xy = XY::new(1, 2);
assert_eq!(xy.map_x(|x| x * 10), XY::new(10, 2));
Source

pub fn map_y<F>(self, f: F) -> XY<T>
where F: FnOnce(T) -> T,

Creates a new XY by applying f to y, and carrying x over.

§Examples
let xy = XY::new(1, 2);
assert_eq!(xy.map_y(|y| y * 10), XY::new(1, 20));
Source

pub fn pair(self) -> (T, T)

Destructure self into a pair.

§Examples
let xy = XY::new(1, 2);
let (x, y) = xy.pair();
assert_eq!((x, y), (1, 2));
Source

pub const fn as_ref(&self) -> XY<&T>

Returns a XY with references to this one’s values.

§Examples
fn longer(xy: &XY<String>, l: usize) -> XY<bool> {
    // `XY::map` takes ownership
    // So we need to get a XY<&String> from a &XY<String>
    let by_ref: XY<&String> = xy.as_ref();
    by_ref.map(|s| s.len() > l)
}

let xy = XY::new(String::from("a"), String::from("bbb"));

assert_eq!(longer(&xy, 2), XY::new(false, true));
Source

pub fn as_ref_mut(&mut self) -> XY<&mut T>

Returns a XY with mutable references to this one’s values.

Source

pub fn iter(&self) -> Chain<Once<&T>, Once<&T>>

Creates an iterator that returns references to x, then y.

§Examples
let xy = XY::new(1, 2);
let vec: Vec<bool> = xy.iter().map(|&i| i > 1).collect();
assert_eq!(vec, vec![false, true]);
Source

pub const fn get(&self, o: Orientation) -> &T

Returns a reference to the value on the given axis.

§Examples
let xy = XY::new(1, 2);
assert_eq!(xy.get(Orientation::Horizontal), &1);
assert_eq!(xy.get(Orientation::Vertical), &2);
Source

pub fn get_mut(&mut self, o: Orientation) -> &mut T

Returns a mutable reference to the value on the given axis.

§Examples
let mut xy = XY::new(1, 2);
*xy.get_mut(Orientation::Horizontal) = 10;

assert_eq!(xy, XY::new(10, 2));
Source

pub fn zip<U>(self, other: XY<U>) -> XY<(T, U)>

Returns a new XY of tuples made by zipping self and other.

§Examples
let a = XY::new(1, 2);
let b = XY::new(true, false);
assert_eq!(a.zip(b), XY::new((1, true), (2, false)));
Source

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.

§Examples
let a = XY::new(1, 2);
let b = XY::new(true, false);
let c = XY::new("x", "y");
assert_eq!(a.zip3(b, c), XY::new((1, true, "x"), (2, false, "y")));
Source

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.

§Examples
let a = XY::new(1, 2);
let b = XY::new(true, false);
let c = XY::new("x", "y");
let d = XY::new(vec![1], vec![2, 3, 4]);
assert_eq!(
    XY::zip4(a, b, c, d),
    XY::new((1, true, "x", vec![1]), (2, false, "y", vec![2, 3, 4]))
);
Source

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.

§Examples
let a = XY::new(1, 2);
let b = XY::new(true, false);
let c = XY::new("x", "y");
let d = XY::new(vec![1], vec![2, 3, 4]);
let e = XY::new('a', 'b');

let xy: XY<Option<char>> = XY::zip5(a, b, c, d, e).map(|(a, b, c, d, e)| {
    if b && d.contains(&a) {
        Some(e)
    } else {
        c.chars().next()
    }
});
assert_eq!(xy, XY::new(Some('a'), Some('y')));
Source

pub fn zip_map<U, V, F>(self, other: XY<U>, f: F) -> XY<V>
where F: FnMut(T, U) -> V,

Returns a new XY by calling f on self and other for each axis.

§Examples
let a = XY::new((1, 10), (2, 20));
let b = XY::new(true, false);
let xy = a.zip_map(b, |(a1, a2), b| if b { a1 } else { a2 });
assert_eq!(xy, XY::new(1, 20));
Source

pub fn keep(self, keep: XY<bool>) -> XY<Option<T>>

For each axis, keep the element from self if keep is true.

§Examples
let xy = XY::new(1, 2);
let cond = XY::new(true, false);

assert_eq!(xy.keep(cond), XY::new(Some(1), None));
Source§

impl<T> XY<T>
where T: Clone,

Source

pub fn with_axis(&self, o: Orientation, value: T) -> XY<T>

Returns a new XY with the axis o set to value.

§Examples
let xy = XY::new(1, 2).with_axis(Orientation::Horizontal, 42);

assert_eq!(xy, XY::new(42, 2));
Source

pub fn with_axis_from(&self, o: Orientation, other: &XY<T>) -> XY<T>

Returns a new XY with the axis o set to the value from other.

§Examples
let other = XY::new(3, 4);
let xy = XY::new(1, 2).with_axis_from(Orientation::Horizontal, &other);

assert_eq!(xy, XY::new(3, 2));
Source

pub fn set_axis_from(&mut self, o: Orientation, other: &XY<T>)

Sets the axis o on self to the value from other.

§Examples
let mut xy = XY::new(1, 2);
let other = XY::new(3, 4);
xy.set_axis_from(Orientation::Horizontal, &other);

assert_eq!(xy, XY::new(3, 2));
Source

pub fn both_from(value: T) -> XY<T>

Creates a XY with both x and y set to value.

§Examples
let xy = XY::both_from(42);

assert_eq!(xy, XY::new(42, 42));
Source§

impl<T> XY<Option<T>>

Source

pub fn unwrap_or(self, other: XY<T>) -> XY<T>

Returns a new XY by calling unwrap_or on each axis.

§Examples
let xy = XY::new(Some(1), None);
assert_eq!(xy.unwrap_or(XY::new(10, 20)), XY::new(1, 20));
Source

pub fn both(self) -> Option<XY<T>>

Returns a new XY if both components are present in self.

§Examples
assert_eq!(XY::new(Some(1), None).both(), None);
assert_eq!(XY::new(Some(1), Some(2)).both(), Some(XY::new(1, 2)));
Source§

impl XY<bool>

Source

pub fn any(self) -> bool

Returns true if any of x or y is true.

§Examples
assert_eq!(XY::new(true, false).any(), true);
assert_eq!(XY::new(false, false).any(), false);
assert_eq!(XY::new('a', 'b').map(|c| c == 'a').any(), true);
Source

pub fn both(self) -> bool

Returns true if both x and y are true.

§Examples
assert_eq!(XY::new(true, false).both(), false);
assert_eq!(XY::new(true, true).both(), true);
assert_eq!(XY::new("abc", "de").map(|s| s.len() > 2).both(), false);
Source

pub fn select<T>(self, other: XY<T>) -> XY<Option<T>>

For each axis, keeps elements from other if self is true.

§Examples
let choice = XY::new(true, false);
let values = XY::new(1, 2);
let selection = choice.select(values);

assert_eq!(selection, XY::new(Some(1), None));
Source

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.

§Examples
let choice = XY::new(true, false);
let values = XY::new(1, 2);
let fallback = XY::new(3, 4);
let selection = choice.select_or(values, fallback);

assert_eq!(selection, XY::new(1, 4));
Source

pub fn and(self, other: XY<bool>) -> XY<bool>

Returns a term-by-term AND operation.

§Examples
let a = XY::new(true, false);
let b = XY::new(true, true);
assert_eq!(a.and(b), XY::new(true, false));
Source

pub fn or(self, other: XY<bool>) -> XY<bool>

Returns a term-by-term OR operation.

§Examples
let a = XY::new(true, false);
let b = XY::new(true, true);
assert_eq!(a.or(b), XY::new(true, true));

Trait Implementations§

Source§

impl<T, O> Add<O> for XY<T>
where T: Add<Output = T>, O: Into<XY<T>>,

Source§

fn add(self, other: O) -> XY<T>

§Examples
let xy = XY::new(1, 2);
assert_eq!(xy + (2, 3), XY::new(3, 5));
Source§

type Output = XY<T>

The resulting type after applying the + operator.
Source§

impl<T> Clone for XY<T>
where T: Clone,

Source§

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

Returns a duplicate 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 for XY<T>
where T: Debug,

Source§

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

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

impl<T> Default for XY<T>
where T: Default,

Source§

fn default() -> XY<T>

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

impl<T> Div<T> for XY<T>
where T: Clone + Div<Output = T>,

Source§

fn div(self, other: T) -> XY<T>

§Examples
let xy = XY::new(1, 4);
assert_eq!(xy / 2, XY::new(0, 2));
Source§

type Output = XY<T>

The resulting type after applying the / operator.
Source§

impl<T> Div for XY<T>
where T: Div,

Source§

fn div(self, other: XY<T>) -> <XY<T> as Div>::Output

§Examples
let u = XY::new(2, 3);
let v = XY::new(1, 2);
assert_eq!(u / v, XY::new(2, 1));
Source§

type Output = XY<<T as Div>::Output>

The resulting type after applying the / operator.
Source§

impl<'a, T> From<&'a XY<T>> for XY<T>
where T: Clone,

Source§

fn from(t: &'a XY<T>) -> XY<T>

Clone a XY

§Examples
let xy = XY::new(String::from("a"), String::from("ab"));
assert_eq!(XY::from(&xy), xy);
Source§

impl<T> From<(T, T)> for XY<T>

Source§

fn from(_: (T, T)) -> XY<T>

A pair is assumed to be (x, y)

Source§

impl<T, U> From<(XY<T>, XY<U>)> for XY<(T, U)>

Source§

fn from(_: (XY<T>, XY<U>)) -> XY<(T, U)>

Easily zip a pair of XY into a XY of pair

Source§

impl From<(i32, i32)> for XY<usize>

Source§

fn from(_: (i32, i32)) -> XY<usize>

§Examples
let xy: XY<isize> = XY::from((-1i32, -2i32));
assert_eq!(xy, XY::new(-1, -2));
Source§

impl From<(u16, u16)> for XY<usize>

Source§

fn from(_: (u16, u16)) -> XY<usize>

§Examples
let v = Vec2::from((1u16, 2u16));
assert_eq!(v, Vec2::new(1, 2));
Source§

impl From<(u32, u32)> for XY<usize>

Source§

fn from(_: (u32, u32)) -> XY<usize>

§Examples
let v = Vec2::from((1u32, 2u32));
assert_eq!(v, Vec2::new(1, 2));
Source§

impl From<(u8, u8)> for XY<usize>

Source§

fn from(_: (u8, u8)) -> XY<usize>

§Examples
let v = Vec2::from((1u8, 2u8));
assert_eq!(v, Vec2::new(1, 2));
Source§

impl<T> From<T> for XY<isize>
where T: Into<XY<usize>>,

Source§

fn from(t: T) -> XY<isize>

§Examples
let u = Vec2::new(1, 2);
let v: XY<isize> = XY::from(u);
assert_eq!(v, XY::new(1, 2));
Source§

impl<T> Hash for XY<T>
where T: Hash,

Source§

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

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 Index<XY<usize>> for ObservedScreen

Source§

type Output = Option<ObservedCell>

The returned type after indexing.
Source§

fn index(&self, index: Vec2) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<XY<usize>> for dyn ObservedPieceInterface

Source§

type Output = Option<ObservedCell>

The returned type after indexing.
Source§

fn index(&self, index: Vec2) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl IndexMut<XY<usize>> for ObservedScreen

Source§

fn index_mut(&mut self, index: Vec2) -> &mut Option<ObservedCell>

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<T> IntoIterator for XY<T>

Source§

fn into_iter(self) -> <XY<T> as IntoIterator>::IntoIter

Iterate over x, then y.

Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = Chain<Once<T>, Once<T>>

Which kind of iterator are we turning this into?
Source§

impl Mul<usize> for XY<usize>

Source§

fn mul(self, other: usize) -> XY<usize>

§Examples
let v = Vec2::new(1, 2);
assert_eq!(v * 2, Vec2::new(2, 4));
Source§

type Output = XY<usize>

The resulting type after applying the * operator.
Source§

impl<T> Mul for XY<T>
where T: Mul,

Source§

fn mul(self, other: XY<T>) -> <XY<T> as Mul>::Output

§Examples
let u = XY::new(1, 2);
let v = XY::new(2, 3);
assert_eq!(u * v, XY::new(2, 6));
Source§

type Output = XY<<T as Mul>::Output>

The resulting type after applying the * operator.
Source§

impl<T> PartialEq<(T, T)> for XY<T>
where T: PartialEq,

Source§

fn eq(&self, _: &(T, T)) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> PartialEq for XY<T>
where T: PartialEq,

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> PartialOrd for XY<T>
where T: PartialOrd,

Source§

fn partial_cmp(&self, other: &XY<T>) -> Option<Ordering>

a < b <=> a.x < b.x && a.y < b.y

1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T> Resolvable for XY<T>
where T: Resolvable + 'static,

Source§

fn from_config(config: &Value, context: &Context) -> Result<XY<T>, Error>

Build from a config (a JSON value). Read more
Source§

fn from_any(any: Box<dyn Any>) -> Option<Self>
where Self: Sized + Any,

Build from an Any variable. Read more
Source§

impl<T, O> Sub<O> for XY<T>
where T: Sub<Output = T>, O: Into<XY<T>>,

Source§

fn sub(self, other: O) -> XY<T>

§Examples
let xy = XY::new(1, 2);
assert_eq!(xy - (1, 0), XY::new(0, 2));
Source§

type Output = XY<T>

The resulting type after applying the - operator.
Source§

impl<T> Copy for XY<T>
where T: Copy,

Source§

impl<T> Eq for XY<T>
where T: Eq,

Source§

impl<T> StructuralPartialEq for XY<T>

Auto Trait Implementations§

§

impl<T> Freeze for XY<T>
where T: Freeze,

§

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

§

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

§

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

§

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

§

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

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

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 T
where U: Into<T>,

Source§

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

Source§

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.
Source§

impl<T> With for T

Source§

fn wrap_with<U, F>(self, f: F) -> U
where F: FnOnce(Self) -> U,

Calls the given closure and return the result. Read more
Source§

fn with<F>(self, f: F) -> Self
where F: FnOnce(&mut Self),

Calls the given closure on self.
Source§

fn try_with<E, F>(self, f: F) -> Result<Self, E>
where F: FnOnce(&mut Self) -> Result<(), E>,

Calls the given closure on self.
Source§

fn with_if<F>(self, condition: bool, f: F) -> Self
where F: FnOnce(&mut Self),

Calls the given closure if condition == true.