Uh oh!
There was an error while loading. Please reload this page.
Environment variable iterator overrides - #31809
Conversation
Allows usage of optimized underlying implementations if any OS supports them.
Will allow optimised usage of `count` now and `nth` & `last` if `IntoIter` ever gets them in the future.
rust-highfive
commented
Feb 21, 2016
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
There was a problem hiding this comment.
To me when I initially read this it wasn't clear why the separation here was needed, could you add a comment explaining why these are separate?
alexcrichton
commented
Feb 22, 2016
Could you add some tests as well which exercise these functions? |
Nemo157
commented
Feb 22, 2016
@alexcrichton done. Again I could only type check the tests as I don't have a windows machine setup for rust dev. I hope using the type alias for |
alexcrichton
commented
Feb 22, 2016
Ah that may be an extra layer or two of indirection which may not be worth it, perhaps just Also, could you move the tests so they cover both the Unix and Windows cases? That should also help exercise the implementation in terms of what's actually being run with |
There was a problem hiding this comment.
Damn, that is... annoying 😦
alexcrichton
commented
Feb 23, 2016
Ok, this looks good to me, could you also squash the commits together? |
Avoids doing the [u16] -> OsString conversion when we don't care about using the env vars.
073e9ec to
52d506eComparealexcrichton
commented
Feb 25, 2016
bors
commented
Feb 25, 2016
⌛ Testing commit 52d506e with merge 9e16bea... |
alexcrichton
commented
Feb 25, 2016
@bors: retry force |
bors
commented
Feb 26, 2016
⌛ Testing commit 52d506e with merge ce41c0e... |
bors
commented
Feb 26, 2016
💔 Test failed - auto-linux-64-x-android-t |
alexcrichton
commented
May 1, 2016
Closing due to inactivity, but feel free to reopen with tests fixed! |
For case #24214, additional iterators mentioned in #24214 (comment).
Overrides
std::env::{ Vars, VarsOs }::{ count, nth, last}to proxy through to their inner iterator (would be nice if there were some iterator wrapper trait that meant these didn't need to be implemented every time an iterator was wrapped...).Overrides
std::sys::unix::os::Env::{ count, nth, last }to proxy through to the innervec::IntoIter. Should makecountfaster, and future proofs in caselastornthget optimised implementations in the future.Overrides
std::sys::windows::Env::{ count, nth, last }to not allocateOsStrings when not needed. Done by defining a sub-iterator that returns the raw pointers and lengths, this uses the default implementations as they should be pretty much equivalent to manually implemented versions, then in the outer iterator does the allocation with the result.I don't have a machine I can actually test the windows changes on, with some hackery (https://gist.github.com/Nemo157/0d1f02b08c132f1a00da) I managed to get the type checker at least running to ensure it should compile. It would be nice if there were some way to test the higher level platform specific code. As far as I can tell testing
windows::Envon unix would work fine if the infrastructure was setup for it.