Skip to content

Fix clippy warning for len_zero #135

@Metmacher

Description

@Metmacher

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.

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