pub trait PointCollection<'a, Coord, CM = BackendCoordOnly> {
type Point: Borrow<Coord> + 'a;
type IntoIter: IntoIterator<Item = Self::Point>;
// Required method
fn point_iter(self) -> Self::IntoIter;
}
Expand description
A type which is logically a collection of points, under any given coordinate system.
Note: Ideally, a point collection trait should be any type of which coordinate elements can be
iterated. This is similar to iter
method of many collection types in std.
trait PointCollection<Coord> {
type PointIter<'a> : Iterator<Item = &'a Coord>;
fn iter(&self) -> PointIter<'a>;
}
However, Generic Associated Types is far away from stabilize. So currently we have the following workaround:
Instead of implement the PointCollection trait on the element type itself, it implements on the reference to the element. By doing so, we now have a well-defined lifetime for the iterator.
In addition, for some element, the coordinate is computed on the fly, thus we can’t hard-code
the iterator’s return type is &'a Coord
.
Borrow
trait seems to strict in this case, since we don’t need the order and hash
preservation properties at this point. However, AsRef
doesn’t work with Coord
This workaround also leads overly strict lifetime bound on ChartContext::draw_series
.
TODO: Once GAT is ready on stable Rust, we should simplify the design.
Required Associated Types§
Sourcetype IntoIter: IntoIterator<Item = Self::Point>
type IntoIter: IntoIterator<Item = Self::Point>
The point iterator
Required Methods§
Sourcefn point_iter(self) -> Self::IntoIter
fn point_iter(self) -> Self::IntoIter
framework to do the coordinate mapping