Conversation
|
(rust-highfive has picked a reviewer for you, use r? to override) |
|
r? @jyn514 |
|
I'm not on T-libs, I shouldn't be the reviewer. r? @dtolnay maybe since they reviewed the initial PR, but it will need FCP either way. |
|
@rust-lang/libs: These two methods on std::iter::Peekable: impl<I: Iterator> Peekable<I> {
+ pub fn next_if(&mut self, func: impl FnOnce(&I::Item) -> bool) -> Option<I::Item>;
+ pub fn next_if_eq<T>(&mut self, expected: &T) -> Option<I::Item>
+ where
+ T: ?Sized,
+ I::Item: PartialEq<T>;
}let alnum = peekable.next_if(char::is_ascii_alphanumeric);
// equivalent to:
let alnum = match peekable.peek() {
Some(ch) if ch.is_ascii_alphanumeric() => Some(peekable.next().unwrap()),
_ => None,
};https://doc.rust-lang.org/nightly/std/iter/struct.Peekable.html#method.next_if |
|
Team member @dtolnay has proposed to merge this. The next step is review by the rest of the tagged team members: Concerns:
Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
|
Why would you need to mutate the item? |
Oh that's an interesting philosophical question... Should we always try offer up the most exclusive reference we can?
I wonder if we asked the same question about With But I think is a shared reference sufficient when we could use an exclusive one? is a good question we should keep asking! |
|
A |
|
@m-ou-se Do you feel strongly that |
|
That sounds good to me. @rfcbot resolve mut |
|
🔔 This is now entering its final comment period, as per the review above. 🔔 |
|
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. The RFC will be merged soon. |
|
@bors r+ |
|
📌 Commit ceda547 has been approved by |
Rollup of 7 pull requests Successful merges: - rust-lang#80011 (Stabilize `peekable_next_if`) - rust-lang#81580 (Document how `MaybeUninit<Struct>` can be initialized.) - rust-lang#81610 (BTreeMap: make Ord bound explicit, compile-test its absence) - rust-lang#81664 (Avoid a hir access inside get_static) - rust-lang#81675 (Make rustdoc respect `--error-format short` in doctests) - rust-lang#81753 (Never MIR inline functions with a different instruction set) - rust-lang#81795 (Small refactor with Iterator::reduce) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This PR stabilizes the
peekable_next_iffeatureResolves #72480