plotters::element

Trait PointCollection

Source
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§

Source

type Point: Borrow<Coord> + 'a

The item in point iterator

Source

type IntoIter: IntoIterator<Item = Self::Point>

The point iterator

Required Methods§

Source

fn point_iter(self) -> Self::IntoIter

framework to do the coordinate mapping

Implementors§

Source§

impl<'a, 'b: 'a, DB: DrawingBackend, Coord: Clone> PointCollection<'a, Coord> for &'a DynElement<'b, DB, Coord>

Source§

impl<'a, Coord> PointCollection<'a, Coord> for &'a PathElement<Coord>

Source§

impl<'a, Coord> PointCollection<'a, Coord> for &'a Pixel<Coord>

Source§

impl<'a, Coord> PointCollection<'a, Coord> for &'a Polygon<Coord>

Source§

impl<'a, Coord> PointCollection<'a, Coord> for &'a Rectangle<Coord>

Source§

impl<'a, Coord, DB: DrawingBackend> PointCollection<'a, Coord> for &'a EmptyElement<Coord, DB>

Source§

impl<'a, Coord, Size: SizeDesc> PointCollection<'a, Coord> for &'a Circle<Coord, Size>

Source§

impl<'a, Coord: 'a, Size: SizeDesc> PointCollection<'a, Coord> for &'a Cross<Coord, Size>

Source§

impl<'a, Coord: 'a, Size: SizeDesc> PointCollection<'a, Coord> for &'a TriangleMarker<Coord, Size>

Source§

impl<'a, I: Iterator + Clone, Size: SizeDesc> PointCollection<'a, <I as Iterator>::Item> for &'a DashedPathElement<I, Size>

Source§

impl<'a, I: Iterator + Clone, Size: SizeDesc, Marker> PointCollection<'a, <I as Iterator>::Item> for &'a DottedPathElement<I, Size, Marker>

Source§

impl<'a, Label: Display> PointCollection<'a, (i32, i32)> for &'a Pie<'a, (i32, i32), Label>

Source§

type Point = &'a (i32, i32)

Source§

type IntoIter = Once<&'a (i32, i32)>

Source§

impl<'a, X: 'a, Y: 'a, Z: 'a> PointCollection<'a, (X, Y, Z), BackendCoordAndZ> for &'a Cubiod<X, Y, Z>

Source§

impl<'b, 'a, Coord: 'a, T: Borrow<str> + 'a> PointCollection<'a, Coord> for &'a MultiLineText<'b, Coord, T>

Source§

impl<'b, 'a, Coord: 'a, T: Borrow<str> + 'a> PointCollection<'a, Coord> for &'a Text<'b, Coord, T>

Source§

impl<'b, Coord, DB: DrawingBackend, A, B> PointCollection<'b, Coord> for &'b ComposedElement<Coord, DB, A, B>
where A: Drawable<DB>, B: Drawable<DB>,