On Mon, May 6, 2013 at 1:36 PM, Graydon Hoare <[email protected]> wrote: > On 13-05-06 09:46 AM, Matthieu Monrocq wrote: > >> I would therefore propose: >> >> - zip: only on collections of equal length >> - zipcut: stop iteration as soon as the shortest collection is exhausted >> - zipfill: fill the "void" (somehow: default value, Option<T>, ...) >> >> This way we have all 3 variants, with descriptive names for those 2 who >> introduce specific behavior. > > This seems to me exactly the sort of "customize how you continue in the > face of a rare event that has multiple reasonable forms of recovery" > that conditions are made for. Do you think they'd be appropriate? > > -Graydon
I like the idea of using conditions for a situation like this, but I'm worried about it being too much of a performance hit in this case. The next() method is a fragment of the loop body, so they really need to be as tiny as possible for LLVM to be able to inline them all and merge the code into one loop. The current zip implementation is a single branch based on whether two enum discriminants are zeroed. _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
