From db375c864798b430f856788df13f8e5cddbb58e7 Mon Sep 17 00:00:00 2001 From: Joonas Muhonen Date: Sun, 14 Dec 2025 12:46:41 +0200 Subject: [PATCH 1/8] cargo clippy fix --- gnuplot/src/datatype.rs | 2 +- gnuplot/src/figure.rs | 7 +++---- gnuplot/src/options.rs | 16 ++++++++-------- gnuplot/src/util.rs | 2 +- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/gnuplot/src/datatype.rs b/gnuplot/src/datatype.rs index 7e630b50..526b298c 100644 --- a/gnuplot/src/datatype.rs +++ b/gnuplot/src/datatype.rs @@ -72,7 +72,7 @@ impl DataType for Duration } } -impl<'l> DataType for &'l Duration +impl DataType for &Duration { fn get(&self) -> f64 { diff --git a/gnuplot/src/figure.rs b/gnuplot/src/figure.rs index 07fb7100..ab0b3768 100644 --- a/gnuplot/src/figure.rs +++ b/gnuplot/src/figure.rs @@ -16,7 +16,6 @@ use std::io::{BufWriter, Write}; use std::path::{Path, PathBuf}; use std::process::{Child, Command, Stdio}; use std::str; -use tempfile; enum AxesVariant { @@ -175,7 +174,7 @@ impl Figure .as_ref() .and_then(|d| d.path().to_str()) .map(|s| s.into()), - data_tempdir: data_tempdir, + data_tempdir, } } @@ -194,7 +193,7 @@ impl Figure if self .data_directory .as_ref() - .map(|s| s == "") + .map(|s| s.is_empty()) .unwrap_or(false) { self.data_directory = self @@ -402,7 +401,7 @@ impl Figure if let Ok(version_string) = str::from_utf8(&output.stdout) { - let parts: Vec<_> = version_string.split(|c| c == ' ' || c == '.').collect(); + let parts: Vec<_> = version_string.split([' ', '.']).collect(); if parts.len() > 2 && parts[0] == "gnuplot" { if let (Ok(major), Ok(minor)) = diff --git a/gnuplot/src/options.rs b/gnuplot/src/options.rs index 18905bad..533f584a 100644 --- a/gnuplot/src/options.rs +++ b/gnuplot/src/options.rs @@ -78,7 +78,7 @@ pub enum PlotOption BoxWidth(Vec), } -impl<'l> OneWayOwned for PlotOption<&'l str> +impl OneWayOwned for PlotOption<&str> { type Output = PlotOption; fn to_one_way_owned(&self) -> Self::Output @@ -258,7 +258,7 @@ pub enum LabelOption MarkerSize(f64), } -impl<'l> OneWayOwned for LabelOption<&'l str> +impl OneWayOwned for LabelOption<&str> { type Output = LabelOption; fn to_one_way_owned(&self) -> Self::Output @@ -295,7 +295,7 @@ pub enum TickOption Format(T), } -impl<'l> OneWayOwned for TickOption<&'l str> +impl OneWayOwned for TickOption<&str> { type Output = TickOption; fn to_one_way_owned(&self) -> Self::Output @@ -376,7 +376,7 @@ pub enum LegendOption MaxCols(u32), } -impl<'l> OneWayOwned for LegendOption<&'l str> +impl OneWayOwned for LegendOption<&str> { type Output = LegendOption; fn to_one_way_owned(&self) -> Self::Output @@ -433,7 +433,7 @@ pub enum PaletteType Custom(T), } -impl<'l> OneWayOwned for PaletteType<&'l [(f32, f32, f32, f32)]> +impl OneWayOwned for PaletteType<&[(f32, f32, f32, f32)]> { type Output = PaletteType>; fn to_one_way_owned(&self) -> Self::Output @@ -472,9 +472,9 @@ impl PaletteType> } Formula(r, g, b) => { - assert!(r >= -36 && r <= 36, "Invalid r formula!"); - assert!(g >= -36 && g <= 36, "Invalid g formula!"); - assert!(b >= -36 && b <= 36, "Invalid b formula!"); + assert!((-36..=36).contains(&r), "Invalid r formula!"); + assert!((-36..=36).contains(&g), "Invalid g formula!"); + assert!((-36..=36).contains(&b), "Invalid b formula!"); writeln!(w, "set palette rgbformulae {},{},{}", r, g, b); } CubeHelix(start, rev, sat, gamma) => diff --git a/gnuplot/src/util.rs b/gnuplot/src/util.rs index 4ee3c0f3..43424237 100644 --- a/gnuplot/src/util.rs +++ b/gnuplot/src/util.rs @@ -161,7 +161,7 @@ pub(crate) trait OneWayOwned fn to_one_way_owned(&self) -> Self::Output; } -impl<'l, T: OneWayOwned> OneWayOwned for &'l [T] +impl OneWayOwned for &[T] { type Output = Vec<::Output>; fn to_one_way_owned(&self) -> Self::Output From 97169cb4fc9623a5b26b1bcf0b8c5a8d33822f93 Mon Sep 17 00:00:00 2001 From: Joonas Muhonen Date: Sun, 14 Dec 2025 12:47:14 +0200 Subject: [PATCH 2/8] cargo fmt --- gnuplot/src/axes_common.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/gnuplot/src/axes_common.rs b/gnuplot/src/axes_common.rs index c1c2455f..79387bb1 100644 --- a/gnuplot/src/axes_common.rs +++ b/gnuplot/src/axes_common.rs @@ -612,12 +612,10 @@ impl PlotType matches!( *self, Lines - | LinesPoints - | XErrorLines + | LinesPoints | XErrorLines | Boxes | YErrorLines - | BoxAndWhisker - | BoxXYError | BoxErrorBars - | Polygons + | BoxAndWhisker | BoxXYError + | BoxErrorBars | Polygons ) } @@ -626,11 +624,9 @@ impl PlotType matches!( *self, Points - | LinesPoints - | XErrorLines - | YErrorLines - | XErrorBars | YErrorBars - | XYErrorBars + | LinesPoints | XErrorLines + | YErrorLines | XErrorBars + | YErrorBars | XYErrorBars ) } From 8688b65e749c0283819e12fb4fd1899cb3cfe0a3 Mon Sep 17 00:00:00 2001 From: Joonas Muhonen Date: Sun, 14 Dec 2025 13:00:56 +0200 Subject: [PATCH 3/8] documentation commit indentation fixes --- gnuplot/src/axes2d.rs | 20 ++++++++++---------- gnuplot/src/axes3d.rs | 10 +++++----- gnuplot/src/axes_common.rs | 16 ++++++++-------- gnuplot/src/color.rs | 2 +- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/gnuplot/src/axes2d.rs b/gnuplot/src/axes2d.rs index 1018e4fd..7b0d569b 100644 --- a/gnuplot/src/axes2d.rs +++ b/gnuplot/src/axes2d.rs @@ -683,8 +683,8 @@ impl Axes2D /// * `BorderColor` - Sets the color of the border /// * `Color` - Sets the color of the box fill /// * `FillAlpha` - Sets the transparency of the box fill - /// * `BoxWidth` - Sets the width of each box. If not supplied, the width will use the - /// previously set box width, or be set to the spacing of the boxes + /// * `BoxWidth` - Sets the width of each box. If not supplied, the width will use the + /// previously set box width, or be set to the spacing of the boxes pub fn boxes< 'l, Tx: DataType, @@ -720,8 +720,8 @@ impl Axes2D /// * `BorderColor` - Sets the color of the border /// * `Color` - Sets the color of the box fill /// * `FillAlpha` - Sets the transparency of the box fill - /// * `BoxWidth` - Sets the width of each box. If not supplied, the width will use the - /// previously set box width, or be set to the spacing of the boxes + /// * `BoxWidth` - Sets the width of each box. If not supplied, the width will use the + /// previously set box width, or be set to the spacing of the boxes pub fn box_error_delta< 'l, Tx: DataType, @@ -763,8 +763,8 @@ impl Axes2D /// * `BorderColor` - Sets the color of the border /// * `Color` - Sets the color of the box fill /// * `FillAlpha` - Sets the transparency of the box fill - /// * `BoxWidth` - Sets the width of each box. If not supplied, the width will use the - /// previously set box width, or be set to the spacing of the boxes + /// * `BoxWidth` - Sets the width of each box. If not supplied, the width will use the + /// previously set box width, or be set to the spacing of the boxes pub fn box_error_low_high< 'l, Tx: DataType, @@ -813,8 +813,8 @@ impl Axes2D /// * `Color` - Sets the color of the box fill /// * `FillAlpha` - Sets the transparency of the box fill /// * `WhiskerBars` - Sets the width of the whisker bars - /// * `BoxWidth` - Sets the width of each box. If not supplied, the width will use the - /// previously set box width, or be set to the spacing of the boxes + /// * `BoxWidth` - Sets the width of each box. If not supplied, the width will use the + /// previously set box width, or be set to the spacing of the boxes pub fn box_and_whisker< 'l, Tx: DataType, @@ -926,11 +926,11 @@ impl Axes2D /// /// #Arguments: /// * `mat` - Row-major 2D array signifying the value of the datapoints. The X and Y coordinates of the datapoints are determined automatically, - /// and optionally scaled using the `dimensions` argument. + /// and optionally scaled using the `dimensions` argument. /// * `num_rows` - Number of rows in the data array /// * `num_cols` - Number of columns in the data array /// * `dimensions` - Optional X and Y coordinates of the first and last data points (with the rest of the coordinates spaced evenly between). - /// By default this will be `(0, 0)` and `(num_rows - 1, num_cols - 1)`. + /// By default this will be `(0, 0)` and `(num_rows - 1, num_cols - 1)`. /// * `options` - Array of PlotOption<&str> controlling the appearance of the surface. Relevant options are: /// * `Caption` - Specifies the caption for this dataset. Use an empty string to hide it (default). pub fn image<'l, T: DataType, X: IntoIterator>( diff --git a/gnuplot/src/axes3d.rs b/gnuplot/src/axes3d.rs index 4f4e9476..3244ea40 100644 --- a/gnuplot/src/axes3d.rs +++ b/gnuplot/src/axes3d.rs @@ -73,11 +73,11 @@ impl Axes3D /// /// #Arguments: /// * `mat` - Row-major 2D array signifying the Z coordinate of the datapoints. The X and Y coordinates of the datapoints are determined automatically, - /// and optionally scaled using the `dimensions` argument. + /// and optionally scaled using the `dimensions` argument. /// * `num_rows` - Number of rows in the data array /// * `num_cols` - Number of columns in the data array /// * `dimensions` - Optional X and Y coordinates of the first and last data points (with the rest of the coordinates spaced evenly between). - /// By default this will be `(0, 0)` and `(num_rows - 1, num_cols - 1)`. + /// By default this will be `(0, 0)` and `(num_rows - 1, num_cols - 1)`. /// * `options` - Array of PlotOption controlling the appearance of the surface. Relevant options are: /// * `Caption` - Specifies the caption for this dataset. Use an empty string to hide it (default). pub fn surface<'l, T: DataType, X: IntoIterator>( @@ -345,9 +345,9 @@ impl Axes3D /// * `surface` - Show the contours on the surface itself /// * `style` - Style of the contours /// * `label` - Auto sets the label automatically and enables the legend, Fix() allows you specify a format string (using C style formatting), - /// otherwise an empty string disables the legend and labels. + /// otherwise an empty string disables the legend and labels. /// * `levels` - Auto picks some default number of levels, otherwise you can pass a set nominal number instead. The number is nominal as - /// contours are placed at nice values of Z, and thus there may be fewer of them than this number. + /// contours are placed at nice values of Z, and thus there may be fewer of them than this number. pub fn show_contours( &mut self, base: bool, surface: bool, style: ContourStyle, label: AutoOption<&str>, levels: AutoOption, @@ -369,7 +369,7 @@ impl Axes3D /// * `surface` - Show the contours on the surface itself /// * `style` - Style of the contours /// * `label` - Auto sets the label automatically and enables the legend, Fix() allows you specify a format string (using C style formatting), - /// otherwise an empty string disables the legend and labels. + /// otherwise an empty string disables the legend and labels. /// * `levels` - A set of levels. pub fn show_contours_custom>( &mut self, base: bool, surface: bool, style: ContourStyle, label: AutoOption<&str>, diff --git a/gnuplot/src/axes_common.rs b/gnuplot/src/axes_common.rs index 79387bb1..eb765dd5 100644 --- a/gnuplot/src/axes_common.rs +++ b/gnuplot/src/axes_common.rs @@ -1372,7 +1372,7 @@ pub trait AxesCommon: AxesCommonPrivate /// * `nrow` - Number of rows in the grid. Must be greater than 0. /// * `ncol` - Number of columns in the grid. Must be greater than 0. /// * `pos` - Which grid cell to place this axes in, counting from top-left corner, - /// going left and then down, starting at 0. + /// going left and then down, starting at 0. fn set_pos_grid(&mut self, nrow: u32, ncol: u32, pos: u32) -> &mut Self { assert!(nrow > 0); @@ -1417,7 +1417,7 @@ pub trait AxesCommon: AxesCommonPrivate /// # Arguments /// * `width` - Width of boxes. /// * `is_relative` - if `true`, `width` is interpreted as a fraction of the default box width. - /// if `false` width is an absolute value in the units of the x axis + /// if `false` width is an absolute value in the units of the x axis fn set_box_width(&mut self, width: f64, is_relative: bool) -> &mut Self { self.get_common_data_mut().box_width = Some((width, is_relative)); @@ -1539,9 +1539,9 @@ pub trait AxesCommon: AxesCommonPrivate /// /// # Arguments /// * `tick_placement` - Controls the placement of the ticks. Pass `None` to hide the ticks. Otherwise, the first tuple value controls the spacing - /// of the major ticks (in axes units), otherwise set it to `Auto` to let gnuplot decide the spacing automatically. The second - /// tuple value specifies the number of minor ticks. For logarithmic axes, non-zero values mean that the number of ticks usually - /// equals to `ceil(log_base) - 2`. + /// of the major ticks (in axes units), otherwise set it to `Auto` to let gnuplot decide the spacing automatically. The second + /// tuple value specifies the number of minor ticks. For logarithmic axes, non-zero values mean that the number of ticks usually + /// equals to `ceil(log_base) - 2`. /// * `tick_options` - Array of TickOption controlling the appearance of the ticks /// * `label_options` - Array of LabelOption<&str> controlling the appearance of the tick labels. Relevant options are: /// * `Offset` - Specifies the offset of the label @@ -1627,8 +1627,8 @@ pub trait AxesCommon: AxesCommonPrivate /// # Arguments /// /// * `ticks` - The locations and labels of the added ticks. - /// The label can contain a single C printf style floating point formatting specifier which will be replaced by the - /// location of the tic. + /// The label can contain a single C printf style floating point formatting specifier which will be replaced by the + /// location of the tic. /// * `tick_options` - Array of TickOption controlling the appearance of the ticks /// * `label_options` - Array of LabelOption<&str> controlling the appearance of the tick labels. Relevant options are: /// * `Offset` - Specifies the offset of the label @@ -2065,7 +2065,7 @@ pub trait AxesCommon: AxesCommonPrivate /// # Arguments /// /// * `margins` - The values of margins to be overriden. Specified as a fraction of the - /// full drawing area, ranging from 0 to 1 + /// full drawing area, ranging from 0 to 1 fn set_margins(&mut self, margins: &[MarginSide]) -> &mut Self { { diff --git a/gnuplot/src/color.rs b/gnuplot/src/color.rs index 91b79bff..a3942ba8 100644 --- a/gnuplot/src/color.rs +++ b/gnuplot/src/color.rs @@ -33,7 +33,7 @@ pub enum ColorType { /// string (`&str` or `String`, but usually created with `&str`) in one of the following gnuplot-supported formats /// - colorname --- e.g. "blue" [See the gnuplot - /// [list of colornames](http://gnuplot.info/docs_6.0/loc11229.html)] + /// [list of colornames](http://gnuplot.info/docs_6.0/loc11229.html)] /// - 0xRRGGBB --- string containing hexadecimal constant /// - 0xAARRGGBB --- string containing hexadecimal constant /// - #RRGGBB --- string containing hexadecimal in x11 format From bbddb6e5d48900cda07dc2349b210b65394db39c Mon Sep 17 00:00:00 2001 From: Joonas Muhonen Date: Sun, 14 Dec 2025 13:03:01 +0200 Subject: [PATCH 4/8] lifetime annotation simplification --- gnuplot/src/color.rs | 2 +- gnuplot/src/options.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gnuplot/src/color.rs b/gnuplot/src/color.rs index a3942ba8..9b67cebe 100644 --- a/gnuplot/src/color.rs +++ b/gnuplot/src/color.rs @@ -297,7 +297,7 @@ impl<'l> From<&'l str> for ColorType } } -impl<'l> From for ColorType +impl From for ColorType { /// Converts `String` into [RGBString] fn from(value: String) -> Self diff --git a/gnuplot/src/options.rs b/gnuplot/src/options.rs index 533f584a..7d6419be 100644 --- a/gnuplot/src/options.rs +++ b/gnuplot/src/options.rs @@ -322,7 +322,7 @@ pub enum Tick Minor(T), } -impl<'l, T: Clone, S: ToString> OneWayOwned for Tick +impl OneWayOwned for Tick { type Output = Tick; fn to_one_way_owned(&self) -> Self::Output From f3c1800be34ac8e306332cd88f9835fa32770eb2 Mon Sep 17 00:00:00 2001 From: Joonas Muhonen Date: Sun, 14 Dec 2025 13:05:05 +0200 Subject: [PATCH 5/8] cargo test warning fix --- gnuplot/examples/variable_color.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gnuplot/examples/variable_color.rs b/gnuplot/examples/variable_color.rs index 84215953..d2d4d641 100644 --- a/gnuplot/examples/variable_color.rs +++ b/gnuplot/examples/variable_color.rs @@ -37,8 +37,8 @@ fn example(c: Common) let d5 = extract_col(4); let d6 = extract_col(5); let row_index: Vec<_> = (1..=d1.len() as u8).collect(); - let by3 = |x| (((x % 3.0) + 1.0) / 6.0); - let by4 = |x| (((x % 4.0) + 1.0) / 7.0); + let by3 = |x| ((x % 3.0) + 1.0) / 6.0; + let by4 = |x| ((x % 4.0) + 1.0) / 7.0; let argb_formula = |x: &f64| { let a = 255.0 - 255.0 * (x - 5.5).abs() / 5.5; From d8e0531939b8f679313ce76456f978f12e1ba518 Mon Sep 17 00:00:00 2001 From: Joonas Muhonen Date: Sun, 14 Dec 2025 13:06:42 +0200 Subject: [PATCH 6/8] TempDir into_path deprecation --- gnuplot/src/figure.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnuplot/src/figure.rs b/gnuplot/src/figure.rs index ab0b3768..11017247 100644 --- a/gnuplot/src/figure.rs +++ b/gnuplot/src/figure.rs @@ -748,7 +748,7 @@ fn flush_test() use std::fs; use tempfile::TempDir; - let tmp_path = TempDir::new().unwrap().into_path(); + let tmp_path = TempDir::new().unwrap().keep(); let filename = tmp_path.join("plot.png"); let mut fg = Figure::new(); fg.axes2d().boxes(0..5, 0..5, &[]); From 90bc0fde11fae489b2b61a2bdf7b24a3fec8f795 Mon Sep 17 00:00:00 2001 From: Joonas Muhonen Date: Sun, 14 Dec 2025 13:17:56 +0200 Subject: [PATCH 7/8] cargo fmt nightly --- gnuplot/src/axes_common.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/gnuplot/src/axes_common.rs b/gnuplot/src/axes_common.rs index eb765dd5..ab8be465 100644 --- a/gnuplot/src/axes_common.rs +++ b/gnuplot/src/axes_common.rs @@ -612,10 +612,12 @@ impl PlotType matches!( *self, Lines - | LinesPoints | XErrorLines + | LinesPoints + | XErrorLines | Boxes | YErrorLines - | BoxAndWhisker | BoxXYError - | BoxErrorBars | Polygons + | BoxAndWhisker + | BoxXYError | BoxErrorBars + | Polygons ) } @@ -624,9 +626,11 @@ impl PlotType matches!( *self, Points - | LinesPoints | XErrorLines - | YErrorLines | XErrorBars - | YErrorBars | XYErrorBars + | LinesPoints + | XErrorLines + | YErrorLines + | XErrorBars | YErrorBars + | XYErrorBars ) } From 80a5ca1fe72c5436a42962ad6feea1477219cb72 Mon Sep 17 00:00:00 2001 From: Joonas Muhonen Date: Sun, 14 Dec 2025 21:49:42 +0200 Subject: [PATCH 8/8] Revert redundant field names lint change and allow remaining lint warnings --- gnuplot/src/axes2d.rs | 1 + gnuplot/src/axes_common.rs | 1 + gnuplot/src/figure.rs | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/gnuplot/src/axes2d.rs b/gnuplot/src/axes2d.rs index 7b0d569b..fff1bde4 100644 --- a/gnuplot/src/axes2d.rs +++ b/gnuplot/src/axes2d.rs @@ -895,6 +895,7 @@ impl Axes2D /// * `BorderColor` - Sets the color of the border /// * `Color` - Sets the color of the box fill /// * `FillAlpha` - Sets the transparency of the box fill + #[allow(clippy::too_many_arguments)] pub fn box_xy_error_low_high< 'l, Tx: DataType, diff --git a/gnuplot/src/axes_common.rs b/gnuplot/src/axes_common.rs index ab8be465..63becd8c 100644 --- a/gnuplot/src/axes_common.rs +++ b/gnuplot/src/axes_common.rs @@ -1088,6 +1088,7 @@ pub struct Size h: f64, } +#[allow(clippy::type_complexity)] pub struct AxesCommonData { pub grid_options: Vec>, diff --git a/gnuplot/src/figure.rs b/gnuplot/src/figure.rs index 11017247..4a28e9b5 100644 --- a/gnuplot/src/figure.rs +++ b/gnuplot/src/figure.rs @@ -160,6 +160,7 @@ impl Figure pub fn new() -> Figure { let data_tempdir = tempfile::tempdir().ok(); + #[allow(clippy::redundant_field_names)] Figure { axes: Vec::new(), terminal: "".into(), @@ -174,7 +175,7 @@ impl Figure .as_ref() .and_then(|d| d.path().to_str()) .map(|s| s.into()), - data_tempdir, + data_tempdir: data_tempdir, } }