Skip to content

Commit

Permalink
Allow borrowing when using from_explicit_callback
Browse files Browse the repository at this point in the history
  • Loading branch information
mo8it committed Sep 13, 2024
1 parent d9030dc commit c39a4d5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions egui_plot/src/items/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl Default for Orientation {
/// These can be an owned `Vec` or generated with a function.
pub enum PlotPoints<'a> {
Owned(Vec<PlotPoint>),
Generator(ExplicitGenerator),
Generator(ExplicitGenerator<'a>),
Borrowed(&'a [PlotPoint]),
}

Expand Down Expand Up @@ -207,7 +207,7 @@ impl<'a> PlotPoints<'a> {

/// Draw a line based on a function `y=f(x)`, a range (which can be infinite) for x and the number of points.
pub fn from_explicit_callback(
function: impl Fn(f64) -> f64 + 'static,
function: impl Fn(f64) -> f64 + 'a,
x_range: impl RangeBounds<f64>,
points: usize,
) -> Self {
Expand Down Expand Up @@ -391,13 +391,13 @@ pub enum PlotGeometry<'a> {
// ----------------------------------------------------------------------------

/// Describes a function y = f(x) with an optional range for x and a number of points.
pub struct ExplicitGenerator {
function: Box<dyn Fn(f64) -> f64>,
pub struct ExplicitGenerator<'a> {
function: Box<dyn Fn(f64) -> f64 + 'a>,
x_range: RangeInclusive<f64>,
points: usize,
}

impl ExplicitGenerator {
impl ExplicitGenerator<'_> {
fn estimate_bounds(&self) -> PlotBounds {
let mut bounds = PlotBounds::NOTHING;

Expand Down

0 comments on commit c39a4d5

Please sign in to comment.