-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(points/2d): move
border
stuff to a separate module
- leave a reexport for backwards-compatibility - mark it as deprecated - doesn't actually work, see^[1] ^[1]: rust-lang/rust#84584
- Loading branch information
Showing
3 changed files
with
30 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use crate::points::Point2D; | ||
use itertools::Itertools; | ||
|
||
#[derive(Debug)] | ||
pub struct Border2D<T, U = T> { | ||
pub left: T, | ||
pub right: T, | ||
pub top: U, | ||
pub down: U, | ||
} | ||
|
||
pub fn min_enclosing_rectangle<'a, I, T, U>(positions1: I, positions2: I) -> Border2D<T, U> | ||
where | ||
T: Copy + PartialOrd + 'a, | ||
U: Copy + PartialOrd + 'a, | ||
I: Iterator<Item = &'a Point2D<T, U>>, | ||
{ | ||
let (left, right) = positions1.map(Point2D::x).minmax().into_option().unwrap(); | ||
let (top, down) = positions2.map(Point2D::y).minmax().into_option().unwrap(); | ||
|
||
Border2D { | ||
left, | ||
right, | ||
top, | ||
down, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#[macro_use] | ||
pub mod parse; | ||
pub mod border; | ||
pub mod direction; | ||
pub mod map; | ||
pub mod points; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters