rust icon indicating copy to clipboard operation
rust copied to clipboard

Variable names that start with an underscore should be removed

Open Baelyk opened this issue 8 years ago • 2 comments

Variables that start with underscores (e.g. _isbn in isbn-verify) should be removed. The reason they are there is to silence unused variable warnings, and there is a better way of doing that (see #442).

Exercises I know of from working on #474:

  • [ ] diffie-hellman
  • [ ] isbn-verifier
  • [ ] series

Baelyk avatar Mar 17 '18 23:03 Baelyk

I think that is in fact all of them.

$ git grep 'fn.*(_[^:]'
exercises/diffie-hellman/src/lib.rs:pub fn private_key(_p: u64) -> u64 {
exercises/diffie-hellman/src/lib.rs:pub fn public_key(_p: u64, _g: u64, _a: u64) -> u64 {
exercises/diffie-hellman/src/lib.rs:pub fn secret(_p: u64, _b_pub: u64, _a: u64) -> u64 {
exercises/isbn-verifier/src/lib.rs:pub fn is_valid_isbn(_isbn: &str) -> bool {
exercises/series/src/lib.rs:pub fn series(_digits: &str, _len: usize) -> Vec<String> {

petertseng avatar Mar 17 '18 23:03 petertseng

NOTE: It is okay that simple-linked-list has an _item. See commit message

     2. Because the element in push is generic over T, which is not bounded
        by Debug, we can't emit it in an unimplemented! statement.
        We therefore fall back on underscore prefixing.

petertseng avatar Aug 14 '18 22:08 petertseng