Rollup of 11 pull requests by Centril · Pull Request #59293 · rust-lang/rust (original) (raw)

Add todo!() macro

The primary use-case of todo!() macro is to be a much easier to type alternative to unimplemented!() macro.

EDIT: hide unpopular proposal about re-purposing unimplemented

However, instead of just replacing `unimplemented!()`, it gives it a more nuanced meaning: a thing which is intentionally left unimplemented and which should not be called at runtime. Usually, you'd like to prevent such cases statically, but sometimes you, for example, have to implement a trait only some methods of which are applicable. There are examples in the wild of code doing this thing, and in this case, the current message of `unimplemented`, "not *yet* implemented" is slightly misleading.

With the addition of TODO, you have three nuanced choices for a !-returning macro (in addition to a good-old panic we all love):

Here's a rough guideline what each one means: