Implement fixes suggested by clippy

This commit is contained in:
Tobias Marschner 2024-02-11 04:44:39 +01:00
parent bf4be8d233
commit 4ba0770fe6
4 changed files with 10 additions and 10 deletions

View File

@ -8,7 +8,7 @@ fn main() {
// Next, read the contents of the input file into a string for easier processing.
let input = std::fs::read_to_string(&args[1]).expect("Error opening file");
// Line-by-line processing is easiest.
let mut input = input.lines();
let input = input.lines();
// --- TASK BEGIN ---
@ -17,7 +17,7 @@ fn main() {
let mut cals = 0u32;
// Iterate line-by-line.
while let Some(line) = input.next() {
for line in input {
// println!("Line is: {line}");
match line.parse::<u32>() {
Ok(num) => cals += num,

View File

@ -8,7 +8,7 @@ fn main() {
// Next, read the contents of the input file into a string for easier processing.
let input = std::fs::read_to_string(&args[1]).expect("Error opening file");
// Line-by-line processing is easiest.
let mut input = input.lines();
let input = input.lines();
// --- TASK BEGIN ---
@ -17,7 +17,7 @@ fn main() {
let mut cals = 0u32;
// Iterate line-by-line.
while let Some(line) = input.next() {
for line in input {
match line.parse::<u32>() {
Ok(num) => cals += num,
Err(_) => {

View File

@ -19,14 +19,14 @@ fn main() {
// Next, read the contents of the input file into a string for easier processing.
let input = std::fs::read_to_string(&args[1]).expect("Error opening file");
// Line-by-line processing is easiest.
let mut input = input.lines();
let input = input.lines();
// --- TASK BEGIN ---
let mut total_score = 0;
while let Some(line) = input.next() {
for line in input {
// Translate the line's first character into its respective shape.
let opponent_shape = match line.chars().nth(0) {
let opponent_shape = match line.chars().next() {
Some('A') => Rock,
Some('B') => Paper,
Some('C') => Scissors,

View File

@ -27,14 +27,14 @@ fn main() {
// Next, read the contents of the input file into a string for easier processing.
let input = std::fs::read_to_string(&args[1]).expect("Error opening file");
// Line-by-line processing is easiest.
let mut input = input.lines();
let input = input.lines();
// --- TASK BEGIN ---
let mut total_score = 0;
while let Some(line) = input.next() {
for line in input {
// Translate the line's first character into its respective shape.
let opponent_shape = match line.chars().nth(0) {
let opponent_shape = match line.chars().next() {
Some('A') => Rock,
Some('B') => Paper,
Some('C') => Scissors,