Skip to content

Fix clippy warning for len_zero #135

Description

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions