Using the todo macro to typecheck unwritten code that will be implemented in the future

InstructorChris Biscardi

Share this video with your friends

Send Tweet

We'll replace the println! macro with a call to todo!, which has the additional benefit of type-checking so we won't need to finish anything with todo! in the expression. Note that if we call a function with todo!, we do get the panic! behavior.

We do have two other options for achieving the same thing, unimplemented! and panic!. All three of these options functionally do the same thing: they crash the program immediately.

We aren't using panic! because panic! should be used when a program reaches an unrecoverable state. We don't have an unrecoverable state so much as a piece of the program we intend to work on later.

For similar reasons, we aren't using unimplemented! because we want to convey that this is something to work on while unimplemented! doesn't necessarily mean that we intend to work on it.