Make Rust questions more idiomatic

I really love Rust. But seeing what leetcode does to Rust makes me sad.
It seems to me, that "people" just tried to convert the template of C++ code to Rust and that's it. Please don't get me wrong, I very much appreciate that Rust is supported, but the way it is, breaks my heart.

For example:

Problem #1 - Two Sum:

Given an array of integers, return indices of the two numbers such that they add up to a specific target.

You get a parameter: pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32>.
What I would like to see: pub fn two_sum(nums: &[u32], target: u32) -> Vec<usize>

Here's why:
You don't have to pass the complete Vec, because we are only intereseted in the numbers itself. See https://stackoverflow.com/questions/40006219
target is always position (at least what I saw). Either make a testcase with negative numbers or make them u32.
The return type should be Vec<usize>, because a usize is the thing you get when you index an array/slice/Vec/w.e. You don't get i32, you don't get u32, no, you'll get usize. That's rust style and it has a reason, so why do you force me to write as i32. That's not idiomatic!


Problem #36 - Valid Sudoku:

Determine if a 9x9 Sudoku board is valid.

Signature: pub fn is_valid_sudoku(board: Vec<Vec<char>>) -> bool

But why? Why isn't this pub fn is_valid_sudoku(board: [[Option<u32>; 9]; 9]) -> bool?

Make it more idiomatic! It's a 9 by 9 grid, so why it gives me two nested Vecs instead? Why a char and not a Option<u32>?


Tl;dr again thanks for supporting Rust! Thanks a lot! But please, if you have the claim to teach and demand peole, let them become good developers and teach them a language properly and not how one would do it in C for example.

I think one could adapt this question to many other languages as well, but I'm not a Javascript/PHP/Go expert, but I love Rust.

My final question: How can I improve the questions? What do I can do, to support leetcode and its community?

Comments (4)