Implement FromIterator for CurveBoundaries

This commit is contained in:
Hanno Braun 2023-10-09 10:34:03 +02:00
parent 70e9587c95
commit 90657b2452
2 changed files with 17 additions and 6 deletions

View File

@ -50,12 +50,10 @@ impl CurveApprox {
impl<const N: usize> From<[CurveApproxSegment; N]> for CurveApprox {
fn from(segments: [CurveApproxSegment; N]) -> Self {
Self {
segments: CurveBoundaries {
inner: segments
.into_iter()
.map(|segment| (segment.boundary, segment.points))
.collect(),
},
segments: segments
.into_iter()
.map(|segment| (segment.boundary, segment.points))
.collect(),
}
}
}

View File

@ -115,6 +115,19 @@ impl<T: CurveBoundariesPayload> Default for CurveBoundaries<T> {
}
}
impl<T: CurveBoundariesPayload> FromIterator<(CurveBoundary<Point<1>>, T)>
for CurveBoundaries<T>
{
fn from_iter<I>(iter: I) -> Self
where
I: IntoIterator<Item = (CurveBoundary<Point<1>>, T)>,
{
Self {
inner: iter.into_iter().collect(),
}
}
}
/// A payload that can be used in [`CurveBoundaries`]
pub trait CurveBoundariesPayload: Clone + Ord {
/// Reverse the orientation of the payload