From 5131cd681b801582fe2e1d7301f01c4d6c9aa103 Mon Sep 17 00:00:00 2001 From: Benny Sjoestrand Date: Fri, 24 Oct 2025 12:43:00 +0200 Subject: [PATCH] For the DualCoordChartContext add borrow_secondary_mut function The function borrow_secondary function does not return a mutable reference. It would be useful if it actually would be possible to get a &mut reference to the secondary context. Implement a new function that actually return a &mut reference to the secondary context. --- plotters/src/chart/dual_coord.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plotters/src/chart/dual_coord.rs b/plotters/src/chart/dual_coord.rs index 048bea02..1d662bcb 100644 --- a/plotters/src/chart/dual_coord.rs +++ b/plotters/src/chart/dual_coord.rs @@ -131,11 +131,17 @@ impl<'a, DB: DrawingBackend, CT1: CoordTranslate, CT2: CoordTranslate> &self.secondary.drawing_area } - /// Borrow a mutable reference to the chart context that uses the secondary + /// Borrow a reference to the chart context that uses the secondary /// coordinate system pub fn borrow_secondary(&self) -> &ChartContext<'a, DB, CT2> { &self.secondary } + + /// Borrow a mutable reference to the chart context that uses the secondary + /// coordinate system + pub fn borrow_secondary_mut(&mut self) -> &mut ChartContext<'a, DB, CT2> { + &mut self.secondary + } } impl