todo! is a Rust standard-library macro for marking unfinished code. It lets a program compile while you sketch its overall structure, but executing the marked code panics. section 11.2
Compile a partial book program
A function can keep its intended signature while postponing its implementation: fn get_book(book: &Book) -> Option<String> { todo!(); } and fn delete_book(book: &Book) -> Result<(), String> { todo!(); }. The surrounding program can compile and run if neither function is called; the example prints "It's hardcover". The return type still must name a type Rust knows.
Use todo! while prototyping, with these limits:
- Keep valid function signatures and declared types; todo! does not hide unknown types or invalid surrounding code. section 11.2
- Treat todo! as temporary: it expands to panic!("not yet implemented") or a formatted equivalent, and is equivalent to unimplemented! for this purpose. section 22.3 section 11.2
