-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Rollup of 6 pull requests #68675
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Rollup of 6 pull requests #68675
Conversation
Brings in a fix for rust-lang/jobserver-rs#23 which could cause Cargo to unnecessarily hang in some situations.
This repr-hint makes a struct/enum hide any niche within from its surrounding type-construction context. It is meant (at least initially) as an implementation detail for resolving issue 68303. We will not stabilize the repr-hint unless someone finds motivation for doing so. (So, declaration of `no_niche` feature lives in section of file where other internal implementation details are grouped, and deliberately leaves out the tracking issue number.) incorporated review feedback, and fixed post-rebase.
…=mark-simulcrum Add `Iterator::map_while` In `Iterator` trait there is `*_map` version of [`filter`] — [`filter_map`], however, there is no `*_map` version of [`take_while`], that can also be useful. ### Use cases In my code, I've found that I need to iterate through iterator of `Option`s, stopping on the first `None`. So I've written code like this: ```rust let arr = [Some(4), Some(10), None, Some(3)]; let mut iter = arr.iter() .take_while(|x| x.is_some()) .map(|x| x.unwrap()); assert_eq!(iter.next(), Some(4)); assert_eq!(iter.next(), Some(10)); assert_eq!(iter.next(), None); assert_eq!(iter.next(), None); ``` Thit code 1) isn't clean 2) In theory, can generate bad bytecode (I'm actually **not** sure, but I think that `unwrap` would generate additional branches with `panic!`) The same code, but with `map_while` (in the original PR message it was named "take_while_map"): ```rust let arr = [Some(4), Some(10), None, Some(3)]; let mut iter = arr.iter().map_while(std::convert::identity); ``` Also, `map_while` can be useful when converting something (as in [examples]). [`filter`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.filter [`filter_map`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.filter_map [`take_while`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.take_while [examples]: https://github.com/rust-lang/rust/compare/master...WaffleLapkin:iter_take_while_map?expand=1#diff-7e57917f962fe6ffdfba51e4955ad6acR1042
…ell, r=oli Hide niches under UnsafeCell Hide any niche of T from type-construction context of `UnsafeCell<T>`. Fix rust-lang#68303 Fix rust-lang#68206
…Dylan-DPC Add missing links for cmp traits r? @Dylan-DPC
…lan-DPC Update jobserver crate to 0.1.21 Brings in a fix for rust-lang/jobserver-rs#23 which could cause Cargo to unnecessarily hang in some situations.
suggest adding space in accidental doc comments Fixes rust-lang#67553. r? @estebank
@bors r+ rollup=never p=6 |
📌 Commit e486f5e has been approved by |
⌛ Testing commit e486f5e with merge 4c61ed74565e9b98e85efd494372e09518190dce... |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
💔 Test failed - checks-azure |
Successful merges:
Iterator::map_while
#66577 (AddIterator::map_while
)Failed merges:
r? @ghost