rust-lang / rustlings

:crab: Small exercises to get you used to reading and writing Rust code!
https://rustlings.cool
MIT License
54.01k stars 10.15k forks source link

Do not use `.as_bytes().len()` on strings #2114

Closed samueltardieu closed 1 month ago

samueltardieu commented 1 month ago

.len() already returns the length in bytes when used on a String or a str. As this might be counter-intuitive for beginners, I've also added an extra comment. This has the benefit of preparing them to a proper use of .len() on a string.

mo8it commented 1 month ago

Thanks :)