turn value_vec_to_tuple into a Trait
This commit is contained in:
parent
b492df826e
commit
5c8d7d4292
@ -363,7 +363,7 @@ impl FunctionEntry {
|
||||
assert!(self.output.back.is_some());
|
||||
let back_data = self.output.back.as_ref().unwrap().clone();
|
||||
assert_eq!(back_data.len(), settings.pixel_width + 1);
|
||||
let back_vec_tuple = value_vec_to_tuple(back_data);
|
||||
let back_vec_tuple = back_data.to_tuple();
|
||||
assert_eq!(back_vec_tuple, back_target);
|
||||
|
||||
assert_eq!(integral_enabled, self.integral);
|
||||
|
||||
18
src/misc.rs
18
src/misc.rs
@ -16,6 +16,17 @@ where
|
||||
input.par_iter()
|
||||
}
|
||||
|
||||
pub trait VecValueToTuple {
|
||||
fn to_tuple(&self) -> Vec<(f64, f64)>;
|
||||
}
|
||||
|
||||
impl VecValueToTuple for Vec<EguiValue>
|
||||
where
|
||||
Self: IntoIterator,
|
||||
{
|
||||
fn to_tuple(&self) -> Vec<(f64, f64)> { self.iter().map(|ele| (ele.x, ele.y)).collect() }
|
||||
}
|
||||
|
||||
/// `SteppedVector` is used in order to efficiently sort through an ordered
|
||||
/// `Vec<f64>` Used in order to speedup the processing of cached data when
|
||||
/// moving horizontally without zoom in `FunctionEntry`. Before this struct, the
|
||||
@ -270,13 +281,6 @@ pub fn step_helper(max_i: usize, min_x: f64, step: f64) -> Vec<f64> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Extracts x and y values from `egui::plot::Value` in `data`. Returns
|
||||
/// `Vec<(f64, f64)>`
|
||||
#[allow(dead_code)]
|
||||
pub fn value_vec_to_tuple(data: Vec<EguiValue>) -> Vec<(f64, f64)> {
|
||||
data.iter().map(|ele| (ele.x, ele.y)).collect()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user