1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use std::iter::FromIterator;
use {CoordinateType, Point};
#[derive(PartialEq, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct MultiPoint<T>(pub Vec<Point<T>>)
where
T: CoordinateType;
impl<T: CoordinateType, IP: Into<Point<T>>> From<IP> for MultiPoint<T> {
fn from(x: IP) -> MultiPoint<T> {
MultiPoint(vec![x.into()])
}
}
impl<T: CoordinateType, IP: Into<Point<T>>> From<Vec<IP>> for MultiPoint<T> {
fn from(v: Vec<IP>) -> MultiPoint<T> {
MultiPoint(v.into_iter().map(|p| p.into()).collect())
}
}
impl<T: CoordinateType, IP: Into<Point<T>>> FromIterator<IP> for MultiPoint<T> {
fn from_iter<I: IntoIterator<Item = IP>>(iter: I) -> Self {
MultiPoint(iter.into_iter().map(|p| p.into()).collect())
}
}
impl<T: CoordinateType> IntoIterator for MultiPoint<T> {
type Item = Point<T>;
type IntoIter = ::std::vec::IntoIter<Point<T>>;
fn into_iter(self) -> Self::IntoIter {
self.0.into_iter()
}
}