Horribly unidiomatic Rust

Hi, not sure where I should speak about that, but the signature of the Rust solution functions in the exercises is not idiomatic at all. Let's take the first problem: Two Sum. The signature to return 2 numbers is:

fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32>

A Rust developper would never use a vector to return a pair of numbers. The appropriate signature is:

fn two_sum(nums: Vec<i32>, target: i32) -> (i32, i32)

I have the feeling that the Rust signatures have been "translated" from another language. Is it possible to change the signatures of the Rust functions in the problems to be more idiomatic?

Comments (2)