Comment Comment by Jarqwiz For me it's a function that calculates factorial using iterators in Rust: fn factorial(i: u64) -> u64 { (1..=i).product() } In almost every other language this code would look messy or use some terrible recursion.For example in C it would look something like this: long factorial(int n) { int c; long result = 1; for (c = 1; c <= n; c++) result = result * c; return result; } Or with recursion: long factorial(int n) { if (n == 0) return 1; else return(n * factorial(n-1)); } In any case, I thin Rust looks better in every way with its cleaner syntax. parent Jarqwiz 7 years ago
For example in C it would look something like this:
Or with recursion: In any case, I thin Rust looks better in every way with its cleaner syntax.