Does Rust have support for functions that return multiple values?

rust

Solution

This works for me:

fn addsub(x: isize, y: isize) -> (isize, isize) {
    (x + y, x - y)
}

It's basically the same as in Go, but the parentheses are required.

Problem

Does Rust have native support for functions that return multiple values like Go? ``` func addsub(x, y int) (int, int) { return x + y, x - y } ``` It seems that we could use a tuple to simulate it. Rosetta Code introduces how to return multiple values in different languages, but I didn't see Rust.

Original source

Related problems