Skip to content

Commit

Permalink
Update book links (#1948)
Browse files Browse the repository at this point in the history
  • Loading branch information
flinguenheld committed Aug 8, 2024
1 parent 289164d commit 178476c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions exercises/practice/triangle/.docs/instructions.append.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

Implementation of this can take many forms. Here are some topics that may help you, depending on the approach you take.

- [Enums](https://doc.rust-lang.org/book/2018-edition/ch06-00-enums.html)
- [Traits](https://doc.rust-lang.org/book/2018-edition/ch10-02-traits.html)
- [Enums](https://doc.rust-lang.org/book/ch06-00-enums.html)
- [Traits](https://doc.rust-lang.org/book/ch10-02-traits.html)
- [BTreeSet](https://doc.rust-lang.org/std/collections/btree_set/struct.BTreeSet.html)

Or maybe you will come up with an approach that uses none of those!
Expand All @@ -17,7 +17,7 @@ integers. However, some triangles cannot be represented by pure integers. A simp

It would be tedious to rewrite the analysis functions to handle both integer and floating-point cases, and particularly tedious to do so for all potential integer and floating point types: given signed and unsigned variants of bitwidths 8, 16, 32, 64, and 128, that would be 10 reimplementations of fundamentally the same code even before considering floats!

There's a better way: [generics](https://doc.rust-lang.org/stable/book/2018-edition/ch10-00-generics.html). By rewriting your Triangle as a `Triangle<T>`, you can write your code once, and hand off the work of generating all those specializations to the compiler. Note that in order to use mathematical operations, you'll need to constrain your generic type to types which support those operations using traits.
There's a better way: [generics](https://doc.rust-lang.org/stable/book/ch10-00-generics.html). By rewriting your Triangle as a `Triangle<T>`, you can write your code once, and hand off the work of generating all those specializations to the compiler. Note that in order to use mathematical operations, you'll need to constrain your generic type to types which support those operations using traits.

There are some bonus tests you can run which test your implementation on floating-point numbers. To enable them, run your tests with the `generic` feature flag, like this:

Expand Down

0 comments on commit 178476c

Please sign in to comment.