“all you need to annotate are function parameters and return values” - true in C++ now too, it’s not just Rust.
“gtest sucks” - it does, but there are far better alternatives. I agree that pytest rocks. I’m curious as to whether dependency injection and mocking are better in Rust than in C++, especially given the lack of compile-time reflection.
In my experience C++ generally requires more annotation of types within a function body, so it is still fair to call out annotating only function parameters and return values as a strength of Rust in particular.
For example in Rust:
// Within the same function body we push a `&str` into the vector
// so compiler understands this must be a `Vec<&str>`.
let mut vec = Vec::new();
vec.push("str");
versus C++:
// Vector element type cannot be inferred.
std::vector<const char *> vec;
vec.push_back("str");
C++17 has constructor template argument deduction, so you can just say auto vec = vector({"str"}) now. Though Rust’s type inference is obviously more powerful.
“all you need to annotate are function parameters and return values” - true in C++ now too, it’s not just Rust.
“gtest sucks” - it does, but there are far better alternatives. I agree that pytest rocks. I’m curious as to whether dependency injection and mocking are better in Rust than in C++, especially given the lack of compile-time reflection.
In my experience C++ generally requires more annotation of types within a function body, so it is still fair to call out annotating only function parameters and return values as a strength of Rust in particular.
For example in Rust:
versus C++:
C++17 has constructor template argument deduction, so you can just say
auto vec = vector({"str"})now. Though Rust’s type inference is obviously more powerful.