Feedback for first Rust Program
Feedback for first Rust Program
I just scrolled through it, so no deep insights, but at first glance it looks pretty good.
One thing I saw, and that probably every rust programmer has to learn in the beginning, is to use slices for function parameters whenever prossible. Pretty much every time you use fn foo(s: &String) you should use fn foo(s: &str) and the same goes for &Vec<T> -> &[T].
Calling these works still the same so just changing the function definitions should work.
The advantage of this is, that now you can use every type that can be dereferenced as the slice, so you can now call foo like this foo(“bar”); or with a String foo(&String::from(“bar”));. The same applies for &[T] which can be called with &Vec<T> or an array &[T; N]