Talk is cheap, show me the code. There are exactly 0 snippets in this article, despite making subjective claims about the language being easier and more intuitive than C/C++ for HPC.
358 karma · joined April 29, 2020
class T {
public:
T(int & m): member{m} {}
int & member;
}
T MakeT(int m) {
return T(m);
}
int main() {
const auto t = MakeT(10);
std::cout << t.member << std::endl; // UB <- member has actually been destroyed
}
Rust will correctly observe that the lifetime of m in `MakeT` is lower than the T object returned and will refuse to compile fn count_nonzero(a: []const i32) i32 {
var count: i32 = 0;
for (items) |value| { // "for" works only on arrays and slices, use >"while" for generic loops.
if (value == 0) {
continue;
}
count += 1; // there is no increment operator, but there are shortcuts for +=, \*=, >>= etc.
}
}After reading this article, I am starting to wonder if people didn't simply migrate to LinkedIn because of the degradation of Facebook's quality as a Social Network and as they still feel the need to share their lives, started sharing those cringe posts.