[][src]Struct bk2d::point::Point

pub struct Point {
    pub x: i32,
    pub y: i32,
}

A point

Example

let point = bk2d::point::Point::new(1, 2);

assert_eq!(point.x, 1);
assert_eq!(point.y, 2);

Fields

x: i32y: i32

Methods

impl Point[src]

pub fn new(x: i32, y: i32) -> Point[src]

pub fn length(self) -> u32[src]

Distance to origin

Example

assert_eq!(bk2d::point::Point::new(1, 2).length(), 3);
assert_eq!(bk2d::point::Point::new(5, -3).length(), 8);

pub fn inside(self, board: Board) -> bool[src]

Point inside board

Example

let board = bk2d::point::Board::new(5, 5);

assert!(bk2d::point::Point::new(0, 4).inside(board));
assert!(bk2d::point::Point::new(3, 0).inside(board));
assert!(bk2d::point::Point::new(3, 4).inside(board));

pub fn outside(self, board: Board) -> bool[src]

Point outside board

Example

let board = bk2d::point::Board::new(5, 5);

assert!(bk2d::point::Point::new(5, 4).outside(board));
assert!(bk2d::point::Point::new(0, 5).outside(board));
assert!(bk2d::point::Point::new(7, -1).outside(board));

Trait Implementations

impl PartialEq<Point> for Point[src]

impl Clone for Point[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Default for Point[src]

impl Eq for Point[src]

impl Copy for Point[src]

impl Debug for Point[src]

impl Sub<Path> for Point[src]

type Output = Point

The resulting type after applying the - operator.

fn sub(self, other: Path) -> Point[src]

Point moves backward on the path

Example

let a = bk2d::point::Point::new(1, 2);
let b = bk2d::point::Path::new(-2, 1);
assert_eq!(a - b, bk2d::point::Point::new(3, 1));

impl Sub<Point> for Point[src]

type Output = Path

The resulting type after applying the - operator.

fn sub(self, other: Point) -> Path[src]

Vector between two points

Example

let a = bk2d::point::Point::new(1, 2);
let b = bk2d::point::Point::new(3, 1);
let sub = a - b;
assert_eq!(sub, bk2d::point::Path::new(-2, 1));
assert_eq!(sub.length(), 3);

impl Add<Path> for Point[src]

type Output = Point

The resulting type after applying the + operator.

fn add(self, other: Path) -> Point[src]

Point moves on the path

Example

let a = bk2d::point::Point::new(3, 1);
let b = bk2d::point::Path::new(-2, 1);
assert_eq!(a + b, bk2d::point::Point::new(1, 2));

impl AddAssign<Path> for Point[src]

fn add_assign(&mut self, other: Path)[src]

Point moves on the path

Example

let mut a = bk2d::point::Point::new(3, 1);
a += bk2d::point::Path::new(-2, 1);
assert_eq!(a, bk2d::point::Point::new(1, 2));

impl SubAssign<Path> for Point[src]

fn sub_assign(&mut self, other: Path)[src]

Point moves backward on the path

Example

let mut a = bk2d::point::Point::new(1, 2);
a -= bk2d::point::Path::new(-2, 1);
assert_eq!(a, bk2d::point::Point::new(3, 1));

Auto Trait Implementations

impl Send for Point

impl Unpin for Point

impl Sync for Point

impl UnwindSafe for Point

impl RefUnwindSafe for Point

Blanket Implementations

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.

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

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

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