Rust

Rust

Made by DeepSource

Found manual implementation of T::BITS RS-W1132

Anti-pattern
Minor

All integer types provide the size of the type in bits through T::BITS. Consider using this instead of manually calling std::mem::size_of::<T>() and multiplying the result by 8.

Bad practice

fn foo() {
    let usize_bits = std::mem::size_of::<usize>() * 8;
    let u32_bits = std::mem::size_of::<u32>() * 8;
}

Recommended

fn foo() {
    let usize_bits = usize::BITS as usize;
    let u32_bits = u32::BITS as usize;
}