Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clippy warning for len_zero #135

Open
Metmacher opened this issue Sep 10, 2024 · 0 comments
Open

Fix clippy warning for len_zero #135

Metmacher opened this issue Sep 10, 2024 · 0 comments

Comments

@Metmacher
Copy link

Summary

When using an AllocRingBuffer from the crate and performing a check with len() == 0, Clippy does not recognize it as an optimization opportunity and does not provide a warning or suggestion. This behavior is inconsistent compared to how Clippy handles standard arrays.

Example

use ringbuffer::{AllocRingBuffer, RingBuffer};

fn main() {
    let buffer: AllocRingBuffer<u32> = AllocRingBuffer::new(5);
    if buffer.len() == 0 {
        println!("Clippy should warn here.");
    }

    let array = [0, 10, 100];
    if array.len() == 0 {
        println!("Clippy does warn here.");
    }
}

To reproduce this, run cargo clippy or cargo +nightly clippy and observe that no warning is triggered for AllocRingBuffer, whereas it works correctly for standard arrays.

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

No branches or pull requests

1 participant