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:

Create a free account to access the full course.

Continue your learning journey with a 14-day free trial.

By signing up, you agree to Educative's Terms of Service and Privacy Policy