Struct palarust::point2d::Point2d [] [src]

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

Point structure in 2 dimensions on an evenly integer spaced grid.

Fields

Methods

impl Point2d
[src]

This function returns true if the point is contained in b ( a 2d box)

Trait Implementations

impl Debug for Point2d
[src]

Formats the value using the given formatter.

impl Clone for Point2d
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Copy for Point2d
[src]

impl Add for Point2d
[src]

The addition of a Point2d with another Point2d

Arguments

  • &self - A Point2d
  • rhs - A Point2d

Example

extern crate palarust;
use palarust::point2d::Point2d;
fn main () {
    let p1 = Point2d::new(1, 4);
    let p2 = Point2d::new(3, 8);
     
    assert_eq!(p1+p2, Point2d::new(4, 12));
}

The resulting type after applying the + operator

The method for the + operator

impl Sub for Point2d
[src]

The subtraction of a Point2d with another Point2d

Arguments

  • &self - A Point2d
  • rhs - A Point2d

Example

extern crate palarust;
use palarust::point2d::Point2d;
fn main () {
    let p1 = Point2d::new(1, 4);
    let p2 = Point2d::new(3, 8);
     
    assert_eq!(p1-p2, Point2d::new(-2, -4));
}

The resulting type after applying the - operator

The method for the - operator

impl Neg for Point2d
[src]

The unary - of a Point2d

Arguments

  • &self - A Point2d

Example

extern crate palarust;
use palarust::point2d::Point2d;
fn main () {
    let p1 = Point2d::new(1, 4);
     
    assert_eq!(-p1, Point2d::new(-1, -4));
}

The resulting type after applying the - operator

The method for the unary - operator

impl PartialEq for Point2d
[src]

The equality of two Point2d

Arguments

  • &self - A Point2d
  • &other - A Point2d

Example

extern crate palarust;
use palarust::point2d::Point2d;
fn main () {
    let b = Point2d::new(1, 4);
     
    assert_eq!(b, Point2d::new(1, 4));
    assert!(b != Point2d::new(1, 5), "b is not equal to Point2d::new(1, 4).");
}

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Add<Box2d> for Point2d
[src]

The addition of a Point2d with a Box2d (in this order)

Arguments

  • self - A Point2d
  • rhs - A Box2d

Example

extern crate palarust;
use palarust::point2d::Point2d;
use palarust::box2d::Box2d;
fn main () {
    let b = Box2d::new(1, 4, 2, 8);
    let p = Point2d::new(-1, 4);
     
    assert_eq!(p+b, b+p);
}

The resulting type after applying the + operator

The method for the + operator