Rust

Rust

Made by DeepSource

Found occurrence of .bytes().count() RS-P1001

Performance
Minor

.bytes().count() is better written as .len() which is easier to read and more performant.

.len() refers to the length property of str and is a constant-time operation. .bytes().count() iterates over the bytes in the string and is a linear-time operation. Replace the call to .bytes().count() with .len() for &str.

Bad practice

"random str".bytes().count()

Recommended

"random str".len()