diff --git a/exercises/luhn-from/.meta/description.md b/exercises/luhn-from/.meta/description.md new file mode 100644 index 000000000..1bf1850e5 --- /dev/null +++ b/exercises/luhn-from/.meta/description.md @@ -0,0 +1,9 @@ +# Luhn: Using the From Trait + +Before doing this exercise you should probably do the original Luhn exercise. If you have not completed Luhn, you can get it by running the command: + +> `exercism fetch rust luhn` + +In the original Luhn exercise you only validated strings, but the Luhn algorithm can be applied to integers as well. + +In this exercise you'll implement the [From trait](https://doc.rust-lang.org/std/convert/trait.From.html) to convert strings, strs and unsigned integers into a Struct that performs the validation. diff --git a/exercises/luhn-from/.meta/metadata.yml b/exercises/luhn-from/.meta/metadata.yml new file mode 100644 index 000000000..bc1e12911 --- /dev/null +++ b/exercises/luhn-from/.meta/metadata.yml @@ -0,0 +1,3 @@ +--- +blurb: "Luhn: Using the From Trait" +source: "The Rust track maintainers, based on the original Luhn exercise" diff --git a/exercises/luhn-trait/.meta/description.md b/exercises/luhn-trait/.meta/description.md new file mode 100644 index 000000000..fd9ce2b3c --- /dev/null +++ b/exercises/luhn-trait/.meta/description.md @@ -0,0 +1,17 @@ +# Luhn: Using a Custom Trait + +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 fetch rust luhn` + +To get the "Luhn: Using the From Trait" exercise, run `exercism fetch rust luhn-from` + +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 you validated the primitives (i.e, String, u8, etc.) themselves? + +In this exercise you'll create and implement a custom [trait](https://doc.rust-lang.org/book/traits.html) that performs the validation. + +Note: It is [not idiomatic Rust to implement traits on on primitives](https://doc.rust-lang.org/book/traits.html#rules-for-implementing-traits). In this exercise we're showing something that you _can_ do, not something you _should_ do. If you find yourself implementing traits on primitives, perhaps you have a case of [Primitive Obsession](http://wiki.c2.com/?PrimitiveObsession). diff --git a/exercises/luhn-trait/.meta/metadata.yml b/exercises/luhn-trait/.meta/metadata.yml new file mode 100644 index 000000000..dfa0c3b26 --- /dev/null +++ b/exercises/luhn-trait/.meta/metadata.yml @@ -0,0 +1,3 @@ +--- +blurb: "Luhn: Using a Custom Trait" +source: "The Rust track maintainters, based on the original Luhn exercise"