[][src]Struct cogs_gamedev::int_coords::ICoord

pub struct ICoord {
    pub x: isize,
    pub y: isize,
}

Signed-int coordinates

Fields

x: isizey: isize

Implementations

impl ICoord[src]

pub fn new(x: isize, y: isize) -> Self[src]

Create a new ICoord

pub fn quadrant(self) -> usize[src]

Return the quadrant this coordinate is in.

  • 1: +X, +Y
  • 2: -X, +Y
  • 3: -X, -Y
  • 4: +X, -Y

Zeroes are treated as positive.

assert_eq!(ICoord::new(4, 5).quadrant(), 1);
assert_eq!(ICoord::new(-3, -2).quadrant(), 3);
// Zero is treated as positive
assert_eq!(ICoord::new(0, -8).quadrant(), 4);
assert_eq!(ICoord::new(0, 0).quadrant(), 1);

Trait Implementations

impl Add<ICoord> for ICoord[src]

type Output = Self

The resulting type after applying the + operator.

impl AddAssign<ICoord> for ICoord[src]

impl Clone for ICoord[src]

impl Copy for ICoord[src]

impl Debug for ICoord[src]

impl Eq for ICoord[src]

impl From<Coord> for ICoord[src]

impl PartialEq<ICoord> for ICoord[src]

impl StructuralEq for ICoord[src]

impl StructuralPartialEq for ICoord[src]

impl TryFrom<ICoord> for Coord[src]

Try to convert an ICoord to a Coord. Will return Error if the ICoord has any negatives in it.

type Error = TryFromIntError

The type returned in the event of a conversion error.

Auto Trait Implementations

impl RefUnwindSafe for ICoord

impl Send for ICoord

impl Sync for ICoord

impl Unpin for ICoord

impl UnwindSafe for ICoord

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.