RustGnuplot icon indicating copy to clipboard operation
RustGnuplot copied to clipboard

Single iterator providing X-Y coordinates

Open Chris00 opened this issue 2 years ago • 2 comments

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) where X and Y 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?

Chris00 avatar Jan 07 '23 12:01 Chris00

@SiegeLord Any opinion on this?

Chris00 avatar Feb 16 '23 11:02 Chris00

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.

SiegeLord avatar Feb 27 '23 02:02 SiegeLord