Skip to content

Remove underscores from exercise stub  #442

Closed
@cbzehner

Description

@cbzehner

Per discussion that began on #438.

Some of the exercise stubs currently use _ as a parameter for their input. This is confusing for beginners since _ binds any pattern (it serves as the default case in matches) and is prefixed to a variable to suppress an underscore.

This is currently used in function stubs as a way of reducing the initial number of compiler warnings encountered on the Rust track and most of these stubs have a body of unimplemented!() and nothing more.

However, in most cases we should be able to easily turn the function input into a regular parameter and avoid compiler warnings by referencing it in the body of our function. So the normal stub:

pub fn exercise(_: &str) -> bool {
  unimplemented!()
}

becomes

pub fn exercise(input: &str) -> bool {
  unimplemented!("There's an easy way to reference your input variable: {}", input)
}

A quick rg -e 'pub fn \w+\(_' --count | sort | cut -f 1 -d '/' shows which exercises are affected (caveat: this might miss some).

  • alphametics
  • book-store
  • crypto-square
  • decimal
  • diffie-hellman
  • isbn-verifier
  • poker
  • reverse-string
  • series

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