Commit 7a3954e4 by Alex Butler

### Merge branch 'impl-Default-for-geometry-structs' into 'master'

```Implement Default for the geometry structs

See merge request redox-os/rusttype!150```
parents abf7b21a 92da5d2e
 ... ... @@ -23,6 +23,15 @@ pub struct Point { pub y: N, } impl Default for Point { fn default() -> Self { Point { x: N::default(), y: N::default() } } } /// A vector in 2-dimensional space, with each dimension of type `N`. /// /// Legal operations on vectors are addition and subtraction by vectors, ... ... @@ -33,6 +42,16 @@ pub struct Vector { pub x: N, pub y: N, } impl Default for Vector { fn default() -> Self { Vector { x: N::default(), y: N::default() } } } /// A convenience function for generating `Point`s. #[inline] pub fn point(x: N, y: N) -> Point { ... ... @@ -143,13 +162,13 @@ impl> ops::Add> for Vector { } /// A straight line between two points, `p[0]` and `p[1]` #[derive(Copy, Clone, Debug, PartialEq, PartialOrd)] #[derive(Copy, Clone, Debug, Default, PartialEq, PartialOrd)] pub struct Line { pub p: [Point; 2], } /// A quadratic Bezier curve, starting at `p[0]`, ending at `p[2]`, with control /// point `p[1]`. #[derive(Copy, Clone, Debug, PartialEq, PartialOrd)] #[derive(Copy, Clone, Debug, Default, PartialEq, PartialOrd)] pub struct Curve { pub p: [Point; 3], } ... ... @@ -160,6 +179,16 @@ pub struct Rect { pub min: Point, pub max: Point, } impl Default for Rect { fn default() -> Self { Rect { min: Point::default(), max: Point::default() } } } impl + Copy> Rect { pub fn width(&self) -> N { self.max.x - self.min.x ... ...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!