X-Git-Url: https://git.ralfj.de/rust-101.git/blobdiff_plain/09a36e34a7b4f163c25fb971771bc4c7edd63e2b..369875f931d841112dd2b6651fc968bb6c569cdb:/src/part02.rs diff --git a/src/part02.rs b/src/part02.rs index f81672b..12faed8 100644 --- a/src/part02.rs +++ b/src/part02.rs @@ -33,7 +33,8 @@ type NumberOrNothing = SomethingOrNothing; // The types are so similar, that we can provide a generic function to construct a `SomethingOrNothing` // from an `Option`, and vice versa. // **Exercise 02.1**: Implement such functions! I provided a skeleton of the solution. Here, -// `panic!` is another macro. This one terminates execution with the given message. +// `unimplemented!` is another macro. This one terminates execution saying that something has not yet +// been implemented. // // Notice the syntax for giving generic implementations to generic types: Think of the first `` // as *declaring* a type variable ("I am doing something for all types `T`"), and the second `` as @@ -44,11 +45,11 @@ type NumberOrNothing = SomethingOrNothing; // Remember that `self` is the `this` of Rust, and implicitly has type `Self`. impl SomethingOrNothing { fn new(o: Option) -> Self { - panic!("Not yet implemented.") + unimplemented!() } fn to_option(self) -> Option { - panic!("Not yet implemented.") + unimplemented!() } } // Observe how `new` does *not* have a `self` parameter. This corresponds to a `static` method