Function Results

We'll cover the following...

So far, we’ve been pretending like all functions produce no result. But this isn’t true. In fact, it’s the opposite: every function produces a result value. By default, the result type of a function is the trusty old unit () we became so familiar with before.

How do we say what the result type of a function is? We use an “arrow”:

Press + to interact
fn main() -> () {
println!("Hello, world!");
}

Adding the -> () to our main function’s definition doesn’t change anything. The ...

Access this course and 1400+ top-rated courses and projects.