fn maybe_set_axis_limits(&self) {
        // Limit-setting can either happen via direct limits or through linked limits. The version
        // of implot we link to here has different APIs for the two (separate per-axis calls for
        // direct, and one call for everything together for linked), hence the code here is a bit
        // clunky and takes the two approaches separately instead of a unified "match".

        // --- Direct limit-setting ---
        if let Some(AxisLimitSpecification::Single(limits, condition)) = &self.x_limits {
            unsafe {
                sys::ImPlot_SetNextPlotLimitsX(
                    limits.Min,
                    limits.Max,
                    *condition as sys::ImGuiCond,
                );
            }
        }

        self.y_limits
            .iter()
            .enumerate()
            .for_each(|(k, limit_spec)| {
                if let Some(AxisLimitSpecification::Single(limits, condition)) = limit_spec {
                    unsafe {
                        sys::ImPlot_SetNextPlotLimitsY(
                            limits.Min,
                            limits.Max,
                            *condition as sys::ImGuiCond,
                            k as i32,
                        );
                    }
                }
            });

        // --- Linked limit-setting ---
        let (xmin_pointer, xmax_pointer) =
            if let Some(AxisLimitSpecification::Linked(value)) = &self.x_limits {
                let mut borrowed = value.borrow_mut();
                (
                    &mut (*borrowed).Min as *mut _,
                    &mut (*borrowed).Max as *mut _,
                )
            } else {
                (std::ptr::null_mut(), std::ptr::null_mut())
            };

        let y_limit_pointers: Vec<(*mut f64, *mut f64)> = self
            .y_limits
            .iter()
            .map(|limit_spec| {
                if let Some(AxisLimitSpecification::Linked(value)) = limit_spec {
                    let mut borrowed = value.borrow_mut();
                    (
                        &mut (*borrowed).Min as *mut _,
                        &mut (*borrowed).Max as *mut _,
                    )
                } else {
                    (std::ptr::null_mut(), std::ptr::null_mut())
                }
            })
            .collect();

        unsafe {
            // Calling this unconditionally here as calling it with all NULL pointers should not
            // affect anything. In terms of unsafety, the pointers should be OK as long as any plot
            // struct that has an Rc to the same data is alive.
            sys::ImPlot_LinkNextPlotLimits(
                xmin_pointer,
                xmax_pointer,
                y_limit_pointers[0].0,
                y_limit_pointers[0].1,
                y_limit_pointers[1].0,
                y_limit_pointers[1].1,
                y_limit_pointers[2].0,
                y_limit_pointers[2].1,
            )
        }
    }
/// Internal helper function to set axis limits in case they are specified.
Internal helper function to set axis limits in case they are specified.
Internal helper function to set axis limits in case they are specified .
fn maybe_set_axis_limits(&self) {
        // Limit-setting can either happen via direct limits or through linked limits. The version
        // of implot we link to here has different APIs for the two (separate per-axis calls for
        // direct, and one call for everything together for linked), hence the code here is a bit
        // clunky and takes the two approaches separately instead of a unified "match".
        // --- Direct limit-setting ---
        if let Some(AxisLimitSpecification::Single(limits, condition)) = &self.x_limits {
            unsafe {
                sys::ImPlot_SetNextPlotLimitsX(
                    limits.Min,
                    limits.Max,
                    *condition as sys::ImGuiCond,
                );
            }
        }
        self.y_limits
            .iter()
            .enumerate()
            .for_each(|(k, limit_spec)| {
                if let Some(AxisLimitSpecification::Single(limits, condition)) = limit_spec {
                    unsafe {
                        sys::ImPlot_SetNextPlotLimitsY(
                            limits.Min,
                            limits.Max,
                            *condition as sys::ImGuiCond,
                            k as i32,
                        );
                    }
                }
            });
        // --- Linked limit-setting ---
        let (xmin_pointer, xmax_pointer) =
            if let Some(AxisLimitSpecification::Linked(value)) = &self.x_limits {
                let mut borrowed = value.borrow_mut();
                (
                    &mut (*borrowed).Min as *mut _,
                    &mut (*borrowed).Max as *mut _,
                )
            } else {
                (std::ptr::null_mut(), std::ptr::null_mut())
            };
        let y_limit_pointers: Vec<(*mut f64, *mut f64)> = self
            .y_limits
            .iter()
            .map(|limit_spec| {
                if let Some(AxisLimitSpecification::Linked(value)) = limit_spec {
                    let mut borrowed = value.borrow_mut();
                    (
                        &mut (*borrowed).Min as *mut _,
                        &mut (*borrowed).Max as *mut _,
                    )
                } else {
                    (std::ptr::null_mut(), std::ptr::null_mut())
                }
            })
            .collect();
        unsafe {
            // Calling this unconditionally here as calling it with all NULL pointers should not
            // affect anything. In terms of unsafety, the pointers should be OK as long as any plot
            // struct that has an Rc to the same data is alive.
            sys::ImPlot_LinkNextPlotLimits(
                xmin_pointer,
                xmax_pointer,
                y_limit_pointers[0].0,
                y_limit_pointers[0].1,
                y_limit_pointers[1].0,
                y_limit_pointers[1].1,
                y_limit_pointers[2].0,
                y_limit_pointers[2].1,
            )
        }
    }
fn maybe_set_axis_limits ( & self ) { // Limit-setting can either happen via direct limits or through linked limits. The version // of implot we link to here has different APIs for the two (separate per-axis calls for // direct, and one call for everything together for linked), hence the code here is a bit // clunky and takes the two approaches separately instead of a unified "match". // --- Direct limit-setting --- if let Some ( AxisLimitSpecification :: Single ( limits , condition ) ) = & self . x_limits { unsafe { sys :: ImPlot_SetNextPlotLimitsX ( limits . Min , limits . Max , * condition as sys :: ImGuiCond , ) ; } } self . y_limits . iter ( ) . enumerate ( ) . for_each ( | ( k , limit_spec ) | { if let Some ( AxisLimitSpecification :: Single ( limits , condition ) ) = limit_spec { unsafe { sys :: ImPlot_SetNextPlotLimitsY ( limits . Min , limits . Max , * condition as sys :: ImGuiCond , k as i32 , ) ; } } } ) ; // --- Linked limit-setting --- let ( xmin_pointer , xmax_pointer ) = if let Some ( AxisLimitSpecification :: Linked ( value ) ) = & self . x_limits { let mut borrowed = value . borrow_mut ( ) ; ( & mut ( * borrowed ) . Min as * mut _ , & mut ( * borrowed ) . Max as * mut _ , ) } else { ( std :: ptr :: null_mut ( ) , std :: ptr :: null_mut ( ) ) } ; let y_limit_pointers : Vec < ( * mut f64 , * mut f64 ) > = self . y_limits . iter ( ) . map ( | limit_spec | { if let Some ( AxisLimitSpecification :: Linked ( value ) ) = limit_spec { let mut borrowed = value . borrow_mut ( ) ; ( & mut ( * borrowed ) . Min as * mut _ , & mut ( * borrowed ) . Max as * mut _ , ) } else { ( std :: ptr :: null_mut ( ) , std :: ptr :: null_mut ( ) ) } } ) . collect ( ) ; unsafe { // Calling this unconditionally here as calling it with all NULL pointers should not // affect anything. In terms of unsafety, the pointers should be OK as long as any plot // struct that has an Rc to the same data is alive. sys :: ImPlot_LinkNextPlotLimits ( xmin_pointer , xmax_pointer , y_limit_pointers [ 0 ] . 0 , y_limit_pointers [ 0 ] . 1 , y_limit_pointers [ 1 ] . 0 , y_limit_pointers [ 1 ] . 1 , y_limit_pointers [ 2 ] . 0 , y_limit_pointers [ 2 ] . 1 , ) } }
Internal helper function to set axis limits in case they are specified.
Internal helper function to set axis limits in case they are specified .
&self
&self