Skip to content

fix : cargo clippy warning and error #3

Open
rtczza wants to merge 2 commits intotyroruyk:mainfrom
rtczza:main
Open

fix : cargo clippy warning and error #3
rtczza wants to merge 2 commits intotyroruyk:mainfrom
rtczza:main

Conversation

@rtczza
Copy link

@rtczza rtczza commented May 14, 2024

clippy tips:

warning: unneeded `return` statement
  --> src/modules/kernel.rs:14:17
   |
14 |                 return Ok(kernel_version);
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
   = note: `#[warn(clippy::needless_return)]` on by default
help: remove `return`
   |
14 -                 return Ok(kernel_version);
14 +                 Ok(kernel_version)
   |

and:

warning: unnecessary `if let` since only the `Ok` variant of the iterator element is used
  --> src/modules/cpu.rs:9:5
   |
9  |       for line in io::BufReader::new(file).lines() {
   |       ^           -------------------------------- help: try: `io::BufReader::new(file).lines().flatten()`
   |  _____|
   | |
10 | |         if let Ok(line) = line {
11 | |             // Check for the "model name" line
12 | |             if line.starts_with("model name") {
...  |
17 | |         }
18 | |     }
   | |_____^
   |
help: ...and remove the `if let` statement in the for loop
  --> src/modules/cpu.rs:10:9
   |
10 | /         if let Ok(line) = line {
11 | |             // Check for the "model name" line
12 | |             if line.starts_with("model name") {
13 | |                 // Extract the model name
...  |
16 | |             }
17 | |         }
   | |_________^
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_flatten
   = note: `#[warn(clippy::manual_flatten)]` on by default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant