Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single iterator providing X-Y coordinates #77

Open
Chris00 opened this issue Jan 7, 2023 · 2 comments
Open

Single iterator providing X-Y coordinates #77

Chris00 opened this issue Jan 7, 2023 · 2 comments

Comments

@Chris00
Copy link
Contributor

Chris00 commented Jan 7, 2023

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
Copy link
Contributor Author

Chris00 commented Feb 16, 2023

@SiegeLord Any opinion on this?

@SiegeLord
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants