[pdm-devel] [PATCH proxmox-yew-comp 12/15] use enumerate() instead of indexing

Maximiliano Sandoval m.sandoval at proxmox.com
Mon Jan 13 15:27:22 CET 2025


Fixes:

warning: the loop variable `i` is used to index `time_data`
   --> src/rrd_graph_new.rs:388:14
    |
388 |     for i in 0..time_data.len() {
    |              ^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_range_loop
    = note: `#[warn(clippy::needless_range_loop)]` on by default
help: consider using an iterator and enumerate()
    |
388 |     for (i, <item>) in time_data.iter().enumerate() {
    |         ~~~~~~~~~~~    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Maximiliano Sandoval <m.sandoval at proxmox.com>
---
 src/rrd_graph_new.rs | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/rrd_graph_new.rs b/src/rrd_graph_new.rs
index 32b6126..f549c4f 100644
--- a/src/rrd_graph_new.rs
+++ b/src/rrd_graph_new.rs
@@ -385,10 +385,9 @@ fn compute_outline_path(
 ) -> String {
     let mut path = String::new();
     let mut last_undefined = true;
-    for i in 0..time_data.len() {
-        let t = time_data[i];
+    for (i, t) in time_data.iter().enumerate() {
         let value = *values.get(i).unwrap_or(&f64::NAN);
-        let x = compute_x(t);
+        let x = compute_x(*t);
 
         if last_undefined {
             if value.is_nan() {
-- 
2.39.5





More information about the pdm-devel mailing list