Weird syntax idea(s) for UMCS

As a user of rust (as opposed to a developer on rust itself), this would be very nice. One use case where I ran into this was when using itertools. Specially the intersperse method from itertools. There is an unstable intersperse method in the std iterator trait.

If I don't use the fully qualified name for the itertools intersperse I got a warning (forget if it was clippy or rustc). If I do use the fully qualified name, I can't use the chain of method calls (i.e. a.iter().something(...).intersperse(...).otherthing().collect()).

Currently I'm forced to break up the chain by either writing it as Itertools::intersperse(a.iter().something(...), ...).otherthing().collect() which means the flow of reading code reverses direction in the middle, which is bad for readability. Or I have to have to stop halfway and assign to a temporary variable. Which is better, but still introduces extra mental load on whoever is reading the code and trying to figure out why I did this seemingly unneeded step.

2 Likes