X-Git-Url: https://git.ralfj.de/rust-101.git/blobdiff_plain/e2374eed1c3ae8d0063138ea011e86bbd42473ab..1b77423cf168e5ff2b41667ea67252f4fbc44652:/src/part02.rs?ds=inline 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