Remix.run Logo
dgfitz 7 months ago

> trait Iterator = fn next<T>(&mut self) -> Option<T> + fn len(&self) -> usize

This is why I don’t have interest in learning rust. When I see people write c++ code like this I wonder why they feel the need to be so clever.

That is an abysmal thing to maintain.

marcosdumay 7 months ago | parent | next [-]

Nope, just because you lack familiarity with the symbols, it doesn't make that declaration complex.

It's not even "clever". It's completely plain, and the bare minimum and obvious definition of what an "iterator" should be.

steveklabnik 7 months ago | parent | prev | next [-]

That isn’t real Rust code, though it’s made up of valid bits of Rust syntax.

dgfitz 7 months ago | parent [-]

Oh, ok that’s fair. I guess I should at least learn the grammar better before commenting more on rust.

moomin 7 months ago | parent | prev [-]

I mean, C#'s IEnumerator is equivalent and is way more complex. You just don't need to think about it much.