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
x: i32
y: i32
Methods
impl Point2d
[src]
fn new(x: i32, y: i32) -> Point2d
fn is_contained(&self, b: Box2d) -> bool
This function returns true if the point is contained in b ( a 2d box)
Trait Implementations
impl Debug for Point2d
[src]
impl Clone for Point2d
[src]
fn clone(&self) -> Point2d
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
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 Point2drhs
- 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)); }
type Output = Point2d
The resulting type after applying the +
operator
fn add(self, rhs: Point2d) -> Point2d
The method for the +
operator
impl Sub for Point2d
[src]
The subtraction of a Point2d with another Point2d
Arguments
&self
- A Point2drhs
- 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)); }
type Output = Point2d
The resulting type after applying the -
operator
fn sub(self, rhs: Point2d) -> Point2d
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)); }
type Output = Point2d
The resulting type after applying the -
operator
fn neg(self) -> Point2d
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)."); }
fn eq(&self, other: &Point2d) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.