|
|
|
|
|
by sph
1264 days ago
|
|
It usually does that on iterator chains, which AFAIK do not exist as such in C++, so multiple operations would be expressed as multiple imperative statements. My C++ is rusty (no pun intended) but I struggle to imagine their variant of `vector.iter().map().collect()` to be as concise and fit in fewer than 4 lines. I wonder if OP's C++ port doesn't use iterators that much, and how idiomatic it is. EDIT: the code is not idiomatic at all. |
|
I think I only used iterators in places where there's no built-in function on slices like C++'s strchr and strspn. (I think Rust's str has these, but not [u8].) For example:
C++: https://github.com/quick-lint/cpp-vs-rust/blob/f8d31341f5cac...
Rust: https://github.com/quick-lint/cpp-vs-rust/blob/f8d31341f5cac...