Make BoundingBox::from_points accept any IntoIterator<Point3<T>>

...instead of only Vec<Point3<T>>
This commit is contained in:
Matthew Gordon 2020-01-29 16:49:30 -05:00
parent e5d7a1098d
commit e67204b96e
1 changed files with 5 additions and 2 deletions

View File

@ -115,9 +115,12 @@ impl<T: RealField> BoundingBox<T> {
} }
} }
pub fn from_points(points: &Vec<Point3<T>>) -> Self { pub fn from_points<'a, I>(points: I) -> Self
where
I: IntoIterator<Item = &'a Point3<T>>,
{
points points
.iter() .into_iter()
.fold(BoundingBox::empty(), |acc, p| acc.expand_to_point(p)) .fold(BoundingBox::empty(), |acc, p| acc.expand_to_point(p))
} }