Fix clippy lints #1

Merged
ro merged 35 commits from federico/love_fipamo:appease-clippy into develop 2025-10-03 22:28:48 +02:00
Contributor

This PR fixes all the lints from cargo clippy. I have tried to gather similar lints into single commits, but there's many lints, so there's a bunch of commits :)

None of this changes functionality; it's just code style as per clippy.

This PR fixes all the lints from `cargo clippy`. I have tried to gather similar lints into single commits, but there's many lints, so there's a bunch of commits :) None of this changes functionality; it's just code style as per clippy.
If you have a variable `foo` with the same name as a struct field
some_struct.foo, you can just initialize the struct field with its
name without specifying the variable.
Instead of

  fn foo() -> Bar {
      let bar = Bar { ... };
      bar
  }

just use

  fn foo() -> Bar {
      Bar { ... }
  }
Also, compare these:

pub struct Global {
    pub render_on_save: bool,
    pub external_api: bool,
    pub dynamic_render: bool,
    ...
}

pub struct GlobalEdit {
    pub render_on_save: String,
    pub external_api: String,
    pub dynamic_render: String,
    ...
}

I think GlobalEdit could use bool fields as well?
range is already i32
This also puts the happy path in the "then", and leaves the "else" for
the error path, which is nicer.
The + operator is defined for String + &str, so for the second operand
we can just ask for the as_str() of an existing String.
This makes it easier to spot cases when a match case forgets to set
either variable.
.trim() just re-slices the given slice, and we can use that for ==
env::var() returns Option<String> already
vec! allocates, but set_audience() takes a &[T] where T: ToString, so
just pass it a static slice.
Collaborator

These changes look great.

Just update this branch with the latest in develop and then I'll merge.

I won't make any changes to the main branch to make it easier.

EDIT: Ha, ok, maybe one little commmit, but that's it. I'll freeze anymore more changes until this is done.

These changes look great. Just update this branch with the latest in `develop` and then I'll merge. I won't make any changes to the main branch to make it easier. EDIT: Ha, ok, maybe one little commmit, but that's it. I'll freeze anymore more changes until this is done.
federico force-pushed appease-clippy from 8553f52351 to 5a36dfa501 2025-10-03 22:27:07 +02:00 Compare
ro merged commit 0bac41c49c into develop 2025-10-03 22:28:48 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: projects/love_fipamo#1
No description provided.