Tracks
/
Rust
Rust
/
Exercises
/
Luhn Trait
Luhn Trait

Luhn Trait

Medium

Instructions

Before doing this exercise you should probably do the original Luhn exercise and its successor, "Luhn: Using the From Trait"

To get the original Luhn exercise, run

exercism download --exercise=luhn --track=rust

To get the "Luhn: Using the From Trait" exercise, run

exercism download --exercise=luhn-from --track=rust

In the original Luhn exercise you only validated strings, but the Luhn algorithm can be applied to integers as well.

In "Luhn: Using the From Trait" you implemented a From trait, which also required you to create a Luhn struct.

Instead of creating a Struct just to perform the validation, what if you validated the primitives (i.e, String, u8, etc.) themselves?

In this exercise you'll create and implement a custom trait that performs the validation.


Source

The Rust track maintainers, based on the original Luhn exercise
Last updated 15 June 2022
Edit via GitHub The link opens in a new window or tab
Rust Exercism

Ready to start Luhn Trait?

Sign up to Exercism to learn and master Rust with 13 concepts, 103 exercises, and real human mentoring, all for free.