...

/

Function With Multiple Return Values

Function With Multiple Return Values

This lesson discusses how we can return multiple values from a function.

Returning Multiple Values

In system programming languages like C++ and C, it is only possible to return a single value or a pointer to an array from a function. However, Rust allows you to return multiple values using a tuple.

Syntax

The function definition for returning multiple values:

The way to return tuple from a function is to just write the tuple:

...