embedded-graphics icon indicating copy to clipboard operation
embedded-graphics copied to clipboard

Polyline is unnecessarily restricting input type to slice of Points

Open mchodzikiewicz opened this issue 2 years ago • 2 comments

I am upgrading my forgotten crate to embedded-graphics 0.7.1, I'd like to get rid of my alternative polyline impl (called DrawableCurve), but here comes the problem:

  • I am mapping abstract coordinates into Polyline
  • Polyline is constructed using slice of Points

so I'd need to unnecessarily collect my conversion iterator just to create a polyline. If it would hold an iterator of points, it would be more flexible for instantiating Polylines from processed data. See my (limited) implementation: https://gitlab.com/mchodzikiewicz/embedded-plots/-/blob/df0b244604b67ab88e44bfcd2bc946a53ecc4ed9/src/curve.rs#L121

mchodzikiewicz avatar Jun 27 '22 17:06 mchodzikiewicz

This is a good idea, and should be possible (with a sizeable refactor). However, Polyline uses a lot of iteration over points internally, so I think the passed Iterator would also need a + Clone bound. Is this a dealbreaker for your specific case?

jamwaffles avatar Jun 27 '22 18:06 jamwaffles

not a problem, my bounds are already I: Iterator<Item = Point> + Clone since I am dealing with the same problem in my DrawableCurve

Since I implemented it already for my crate, I might give it a try soon.

Any requirements / hints on your side?

mchodzikiewicz avatar Jun 27 '22 18:06 mchodzikiewicz