primitive-type
Rust (): represent a successful computation with no useful result
The unit type is the empty tuple; its only value is (). Functions without an explicit return type return unit. Unit is not the never type: a unit-returning function can finish normally. Expected output (not executed): Saved () Why: The function prints a message and completes normally with the unit value. Common mistake: A semicolon on a final expression discards its value; it may change a function body’s result to unit.
Formal Syntax & Structure
rust syntaxrust
()Working Example
Example Snippetrust
fn report() { println!("Saved"); }
fn main() { let result: () = report(); println!("{result:?}");}