Skip to content

Make clippy (mostly) happy - #5

Open
virtualritz wants to merge 2 commits into
Gab-Menezes:mainfrom
virtualritz:clippy
Open

Make clippy (mostly) happy#5
virtualritz wants to merge 2 commits into
Gab-Menezes:mainfrom
virtualritz:clippy

Conversation

@virtualritz

@virtualritz virtualritz commented Jan 30, 2025

Copy link
Copy Markdown

These are almost entirely automatic fixes that cargo clippy --fix yielded.

As a result of those the next clippy run indentified some superfluous lifetimes that I removed.

Left is SeachResult::len(). This popped up because SearchResult misses is_empty(), the companion of len() that clippy laments should always be implemented. 😁

However, a Rust user would be suprised that len() returns Option<usize> and not usize.

I see two possibilities:

  • Rename SearchResult::len() to try_len() to make it obvious that this returns an Option (or could even be Result and return the original Err) and keep the signature.

  • Make it return an usize, i.e. map a possible encountered Err/None inside the function to the 0usize return value.

    In this case also add:

    fn is_empty(&self) -> bool {
        0 == self.len()
    }

@virtualritz

Copy link
Copy Markdown
Author

Ah yeah, this is based on my previous PR which you can ignore if you merge this.

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