Skip to content

Commit

Permalink
Merge #433
Browse files Browse the repository at this point in the history
433: Fix issue #429 r=frewsxcv a=seatonullberg

Implement From\<Triangle\> for Polygon. I was unsure where to add a test or if one is necessary. Please let me know if I should though.

Co-authored-by: Seaton Ullberg <[email protected]>
  • Loading branch information
bors[bot] and seatonullberg authored Mar 30, 2020
2 parents 2763279 + 9e520d5 commit a057c21
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion geo-types/src/polygon.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{CoordinateType, LineString, Point, Rect};
use crate::{CoordinateType, LineString, Point, Rect, Triangle};
use num_traits::{Float, Signed};

/// A bounded two-dimensional area.
Expand Down Expand Up @@ -426,3 +426,9 @@ impl<T: CoordinateType> From<Rect<T>> for Polygon<T> {
)
}
}

impl<T: CoordinateType> From<Triangle<T>> for Polygon<T> {
fn from(t: Triangle<T>) -> Polygon<T> {
Polygon::new(vec![t.0, t.1, t.2, t.0].into(), Vec::new())
}
}

0 comments on commit a057c21

Please sign in to comment.