mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 23:34:48 +00:00
Use iter::from_fn in String::remove_matches
This commit is contained in:
parent
3740ba2a7d
commit
38013e708e
@ -48,7 +48,7 @@ use core::fmt;
|
||||
use core::hash;
|
||||
#[cfg(not(no_global_oom_handling))]
|
||||
use core::iter::FromIterator;
|
||||
use core::iter::FusedIterator;
|
||||
use core::iter::{from_fn, FusedIterator};
|
||||
#[cfg(not(no_global_oom_handling))]
|
||||
use core::ops::Add;
|
||||
#[cfg(not(no_global_oom_handling))]
|
||||
@ -1290,15 +1290,9 @@ impl String {
|
||||
{
|
||||
use core::str::pattern::Searcher;
|
||||
|
||||
let matches = {
|
||||
let matches: Vec<_> = {
|
||||
let mut searcher = pat.into_searcher(self);
|
||||
let mut matches = Vec::new();
|
||||
|
||||
while let Some(m) = searcher.next_match() {
|
||||
matches.push(m);
|
||||
}
|
||||
|
||||
matches
|
||||
from_fn(|| searcher.next_match()).collect()
|
||||
};
|
||||
|
||||
let len = self.len();
|
||||
|
Loading…
Reference in New Issue
Block a user