Auto merge of #33312 - Byron:double-ended-iterator-for-args, r=alexcrichton
DoubleEndedIterator for Args This PR implements the DoubleEndedIterator trait for the `std::env::Args[Os]` structure, as well as the internal implementations. It is primarily motivated by me, as I happened to implement a simple `reversor` program many times now, which so far had to use code like this: ```Rust for arg in std::env::args().skip(1).collect::<Vec<_>>().iter().rev() {} ``` ... even though I would have loved to do this instead: ```Rust for arg in std::env::args().skip(1).rev() {} ``` The latter is more natural, and I did not find a reason for not implementing it. After all, on every system, the number of arguments passed to the program are known at runtime. To my mind, it follows KISS, and does not try to be smart at all. Also, there are no unit-tests, primarily as I did not find any existing tests for the `Args` struct either. The windows implementation is basically a copy-pasted variant of the `next()` method implementation, and I could imagine sharing most of the code instead. Actually I would be happy if the reviewer would ask for it.
Showing
想要评论请 注册 或 登录