Skip to content

Replace Manual Modulo (%) checks with .is_multiple_of() #925

@showmyth

Description

@showmyth

Clippy is reporting 21 instances where % should be replaced with the .is_multiple_of() method for better code clarity and idiomaticity.

List of Affected Files :

  • src/ciphers/aes.rs (lines 321, 351)
  • src/ciphers/blake2b.rs (line 58)
  • src/ciphers/sha3.rs (line 274)
  • src/data_structures/probabilistic/bloom_filter.rs (line 112)
  • src/general/permutations/heap.rs (line 26)
  • src/math/aliquot_sum.rs (line 14)
  • src/math/collatz_sequence.rs (line 9)
  • src/math/factors.rs (line 10)
  • src/math/interquartile_range.rs (lines 15, 32)
  • src/math/perfect_numbers.rs (line 5)
  • src/math/pollard_rho.rs (lines 140, 204)
  • src/math/prime_check.rs (lines 4, 10)
  • src/math/prime_factors.rs (line 8)
  • src/math/quadratic_residue.rs (line 81)
  • src/number_theory/euler_totient.rs (lines 9, 12)

Required Changes

Replace patterns like:
number % divisor == 0 OR number % divisor != 0 with number.is_multiple_of(divisor)

Clippy Warning

error: manual implementation of .is_multiple_of()
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_multiple_of

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions