misc: use lifetimes for EguiHelper
This commit is contained in:
parent
4a4bce90d0
commit
74813f5f13
18
src/misc.rs
18
src/misc.rs
@ -1,4 +1,4 @@
|
||||
use base64::{Engine as _, engine::general_purpose};
|
||||
use base64::{engine::general_purpose, Engine as _};
|
||||
use egui_plot::{Line, PlotPoint, PlotPoints, Points};
|
||||
use emath::Pos2;
|
||||
use getrandom::getrandom;
|
||||
@ -8,13 +8,13 @@ use parsing::FlatExWrapper;
|
||||
/// Implements traits that are useful when dealing with Vectors of egui's `Value`
|
||||
pub trait EguiHelper {
|
||||
/// Converts to `egui::plot::Values`
|
||||
fn to_values(self) -> PlotPoints;
|
||||
fn to_values(self) -> PlotPoints<'static>;
|
||||
|
||||
/// Converts to `egui::plot::Line`
|
||||
fn to_line(self) -> Line;
|
||||
fn to_line(self) -> Line<'static>;
|
||||
|
||||
/// Converts to `egui::plot::Points`
|
||||
fn to_points(self) -> Points;
|
||||
fn to_points(self) -> Points<'static>;
|
||||
|
||||
/// Converts Vector of Values into vector of tuples
|
||||
fn to_tuple(self) -> Vec<(f64, f64)>;
|
||||
@ -22,18 +22,18 @@ pub trait EguiHelper {
|
||||
|
||||
impl EguiHelper for Vec<PlotPoint> {
|
||||
#[inline(always)]
|
||||
fn to_values(self) -> PlotPoints {
|
||||
fn to_values(self) -> PlotPoints<'static> {
|
||||
PlotPoints::from(unsafe { std::mem::transmute::<Vec<PlotPoint>, Vec<[f64; 2]>>(self) })
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn to_line(self) -> Line {
|
||||
Line::new(self.to_values())
|
||||
fn to_line(self) -> Line<'static> {
|
||||
Line::new("", self.to_values())
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn to_points(self) -> Points {
|
||||
Points::new(self.to_values())
|
||||
fn to_points(self) -> Points<'static> {
|
||||
Points::new("", self.to_values())
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user