-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Description
Is your feature request related to a problem? Please describe.
Currently, all methods like Plot::{x,y}_grid_spacer or Plot::{x,y}_axis_formatter take an impl Fn... + 'static which is quite impractical mainly because these methods can easily require some access to self or other borrowed data.
Describe the solution you'd like
Introduce a lifetime for the Plot struct? Since a Plot is rarely stored in another struct, this shouldn't be too much of an issue.
Describe alternatives you've considered
Not using borrowed data or some sketchy shit with RefCells
Additional context
Basic example:
struct App {
data: (),
}
impl App {
pub fn draw(&self, ctx: &egui::Context) {
egui::CentralPanel::default().show(ctx, |ui| {
egui_plot::Plot::new("plot")
.x_axis_formatter(|_, _, _| format!("{:?}", self.data))
.show(ui, |_| {});
});
}
}This does currently not work because x_axis_formatter requires a 'static lifetime
pub fn x_axis_formatter(self, fmt: impl Fn(GridMark, usize, &RangeInclusive<f64>) -> String + 'static) -> SelfMetadata
Metadata
Assignees
Labels
No labels