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

Implement From and FromIterator for widgets::plot::Value(s) #1843

Closed
wants to merge 1 commit into from

Conversation

KmolYuan
Copy link
Contributor

  • Implement From for widgets::plot::Value, for [f64; 2], (f64, f64) and their valid type.
  • Implement FromIterator for widgets::plot::Values, for any iterator containing Value type.
  • Use IntoIterator to support the types that can deconstruct themselves.

This PR makes the following code work:

use egui::widgets::plot::Values;

let v: Vec<MyType>;
let values = v.iter()
    // do the iterator things
    .map(|my| [my.x(), my.y()])
    .collect::<Values>();

Before:

use egui::widgets::plot::{Value, Values};

let v: Vec<MyType>;
let iter = v.iter()
    // do the iterator things
    .map(|my| Value::new(my.x(), my.y()));
let values = Values::from_values_iter(iter);

@KmolYuan KmolYuan changed the title Implemnt From and FromIterator for widgets::plot::Value(s) Implement From and FromIterator for widgets::plot::Value(s) Jul 23, 2022
@EmbersArc
Copy link
Contributor

Hey, have a look at #1816 which adds this amongst other small improvements. Feel free to make suggestions there.

@emilk emilk mentioned this pull request Jul 23, 2022
@emilk
Copy link
Owner

emilk commented Aug 2, 2022

Is this still relevant after #1816 ?

@KmolYuan
Copy link
Contributor Author

KmolYuan commented Aug 2, 2022

@emilk This PR is fully covered in #1816.

@emilk emilk closed this Aug 2, 2022
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

Successfully merging this pull request may close these issues.

3 participants