macro
todo! — Mark code that still needs implementation
Leave a deliberate placeholder that panics if reached. Its diverging behavior allows an unfinished branch to type-check in many contexts; it does not supply a valid return value. Use it during development, with an explicit plan to replace it before shipping reachable code. Expression result: !. Expected result (not executed): stdout: 'Standard shipping: 5\n'; no stderr. Common mistake: Believing todo! is a comment or compiler-enforced prohibition on building unfinished code.
Formal Syntax & Structure
rust syntaxrust
todo!() or todo!("message", arguments...)Working Example
Example Snippetrust
fn shipping(express: bool) -> u32 { if express { todo!("express rate"); } 5}fn main() { println!("Standard shipping: {}", shipping(false)); }