RustGnuplot
RustGnuplot copied to clipboard
Single iterator providing X-Y coordinates
Often, the X-Y coordinates come from a single iterator. Having to close that iterator and project on X and Y components is not very ergonomic.
Sadly, I do not see any way of improving that without breaking backward compatibility (one could define new methods but that would not be ergonomic either). My idea is to generalize plotting functions as
pub fn points(&'l mut self, xy: impl XY,
options: &[PlotOption<&str>]) -> &'l mut Self
where the trait XY
(or a longer name such as XYcoordinates
) is implemented for
-
(X, Y)
whereX
andY
are as before so older code simply has to add 2 parentheses, -
IntoIterator<Item = &[(Tx, Ty)]
-
IntoIterator<Item = &[[T; 2]]
and maybe other types for which it makes sense.
What do you think?
@SiegeLord Any opinion on this?
I don't think I want to make the two iterator case require more typing for the sake of one iterator case. The internal API could be written in this way however, and perhaps the internal API can be made public.