Rust generics are nice

I just did the Triangle exercise in Rust on Exercism. First I did it as written so that it only handled 64-bit integers. Then I changed it for the "extra credit" so that it also handled floating-point numbers or whatever else. I'm not suggesting this is the best way to do this, but I was pleased that all of the changes were in the first few lines. Here is an ediff with the non-generic on the left and the generic on the right.

./diff.png

It's mostly changing u64 to T and then figuring out what trait bounds you need (that big where clause). After that, things like ==, +, and < work as before. Interestingly, I had to change 0 to T::default() myself.

There's more that scrolled off the bottom, but it doesn't matter because it's identical in both versions. Indeed that's what I'm so pleased about.