+ self.data == other.data /*@*/
+ }
+}
+
+//@ Since implementing `PartialEq` is a fairly mechanical business, you can let Rust automate this
+//@ by adding the attribute `derive(PartialEq)` to the type definition. In case you wonder about
+//@ the "partial", I suggest you check out the documentation of
+//@ [`PartialEq`](https://doc.rust-lang.org/std/cmp/trait.PartialEq.html) and
+//@ [`Eq`](https://doc.rust-lang.org/std/cmp/trait.Eq.html). `Eq` can be automatically derived as
+//@ well.
+
+// Now we can compare `BigInt`s. Rust treats `PartialEq` special in that it is wired to the operator
+// `==`:
+//@ That operator can now be used on our numbers! Speaking in C++ terms, we just overloaded the
+//@ `==` operator for `BigInt`. Rust does not have function overloading (i.e., it will not dispatch
+//@ to different functions depending on the type of the argument). Instead, one typically finds (or
+//@ defines) a trait that catches the core characteristic common to all the overloads, and writes a
+//@ single function that's generic in the trait. For example, instead of overloading a function for
+//@ all the ways a string can be represented, one writes a generic functions over
+//@ [ToString](https://doc.rust-lang.org/std/string/trait.ToString.html).
+//@ Usually, there is a trait like this that fits the purpose - and if there is, this has the great
+//@ advantage that any type *you* write, that can convert to a string, just has to implement
+//@ that trait to be immediately usable with all the functions out there that generalize over
+//@ `ToString`.
+//@ Compare that to C++ or Java, where the only chance to add a new overloading variant is to
+//@ edit the class of the receiver.
+//@
+//@ Why can we also use `!=`, even though we just overloaded `==`? The answer lies in what's called
+//@ a *default implementation*. If you check out the documentation of `PartialEq` I linked above,
+//@ you will see that the trait actually provides two methods: `eq` to test equality, and `ne` to
+//@ test inequality. As you may have guessed, `!=` is wired to `ne`. The trait *definition* also
+//@ provides a default implementation of `ne` to be the negation of `eq`. Hence you can just
+//@ provide `eq`, and `!=` will work fine. Or, if you have a more efficient way of deciding
+//@ inequality, you can provide `ne` for your type yourself.
+fn compare_big_ints() {
+ let b1 = BigInt::new(13);
+ let b2 = BigInt::new(37);
+ println!("b1 == b1: {} ; b1 == b2: {}; b1 != b2: {}", b1 == b1, b1 == b2, b1 != b2);
+}
+
+// ## Testing
+// With our equality test written, we are now ready to write our first testcase.
+//@ It doesn't get much simpler: You just write a function (with no arguments or return value),
+//@ and give it the `test` attribute. `assert!` is like `debug_assert!`, but does not get compiled
+//@ away in a release build.
+#[test]
+fn test_min() {
+ let b1 = BigInt::new(1);
+ let b2 = BigInt::new(42);
+ let b3 = BigInt::from_vec(vec![0, 1]);
+
+ assert!(*b1.min(&b2) == b1); /*@*/
+ assert!(*b3.min(&b2) == b2); /*@*/
+}
+// Now run `cargo test` to execute the test. If you implemented `min` correctly, it should all work!
+
+// ## Formatting
+//@ There is also a macro `assert_eq!` that's specialized to test for equality, and that prints the
+//@ two values (left and right) if they differ. To be able to do that, the macro needs to know how
+//@ to format the value for printing. This means that we - guess what? - have to implement an
+//@ appropriate trait. Rust knows about two ways of formatting a value: `Display` is for pretty-
+//@ printing something in a way that users can understand, while `Debug` is meant to show the
+//@ internal state of data and targeted at the programmer. The latter is what we want for
+//@ `assert_eq!`, so let's get started.
+
+// All formating is handled by [`std::fmt`](https://doc.rust-lang.org/std/fmt/index.html). I won't
+// explain all the details, and refer you to the documentation instead.
+use std::fmt;
+
+//@ In the case of `BigInt`, we'd like to just output our internal `data` array, so we
+//@ simply call the formating function of `Vec<u64>`.
+impl fmt::Debug for BigInt {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ self.data.fmt(f)