@@ -2232,6 +2232,14 @@ impl<'a, K, V> Iterator for Iter<'a, K, V> {
2232
2232
fn size_hint(&self) -> (usize, Option<usize>) {
2233
2233
self.base.size_hint()
2234
2234
}
2235
+ #[inline]
2236
+ fn fold<B, F>(self, init: B, f: F) -> B
2237
+ where
2238
+ Self: Sized,
2239
+ F: FnMut(B, Self::Item) -> B,
2240
+ {
2241
+ self.base.fold(init, f)
2242
+ }
2235
2243
}
2236
2244
#[stable(feature = "rust1", since = "1.0.0")]
2237
2245
impl<K, V> ExactSizeIterator for Iter<'_, K, V> {
@@ -2256,6 +2264,14 @@ impl<'a, K, V> Iterator for IterMut<'a, K, V> {
2256
2264
fn size_hint(&self) -> (usize, Option<usize>) {
2257
2265
self.base.size_hint()
2258
2266
}
2267
+ #[inline]
2268
+ fn fold<B, F>(self, init: B, f: F) -> B
2269
+ where
2270
+ Self: Sized,
2271
+ F: FnMut(B, Self::Item) -> B,
2272
+ {
2273
+ self.base.fold(init, f)
2274
+ }
2259
2275
}
2260
2276
#[stable(feature = "rust1", since = "1.0.0")]
2261
2277
impl<K, V> ExactSizeIterator for IterMut<'_, K, V> {
@@ -2290,6 +2306,14 @@ impl<K, V> Iterator for IntoIter<K, V> {
2290
2306
fn size_hint(&self) -> (usize, Option<usize>) {
2291
2307
self.base.size_hint()
2292
2308
}
2309
+ #[inline]
2310
+ fn fold<B, F>(self, init: B, f: F) -> B
2311
+ where
2312
+ Self: Sized,
2313
+ F: FnMut(B, Self::Item) -> B,
2314
+ {
2315
+ self.base.fold(init, f)
2316
+ }
2293
2317
}
2294
2318
#[stable(feature = "rust1", since = "1.0.0")]
2295
2319
impl<K, V> ExactSizeIterator for IntoIter<K, V> {
@@ -2320,6 +2344,14 @@ impl<'a, K, V> Iterator for Keys<'a, K, V> {
2320
2344
fn size_hint(&self) -> (usize, Option<usize>) {
2321
2345
self.inner.size_hint()
2322
2346
}
2347
+ #[inline]
2348
+ fn fold<B, F>(self, init: B, mut f: F) -> B
2349
+ where
2350
+ Self: Sized,
2351
+ F: FnMut(B, Self::Item) -> B,
2352
+ {
2353
+ self.inner.fold(init, |acc, (k, _)| f(acc, k))
2354
+ }
2323
2355
}
2324
2356
#[stable(feature = "rust1", since = "1.0.0")]
2325
2357
impl<K, V> ExactSizeIterator for Keys<'_, K, V> {
@@ -2343,6 +2375,14 @@ impl<'a, K, V> Iterator for Values<'a, K, V> {
2343
2375
fn size_hint(&self) -> (usize, Option<usize>) {
2344
2376
self.inner.size_hint()
2345
2377
}
2378
+ #[inline]
2379
+ fn fold<B, F>(self, init: B, mut f: F) -> B
2380
+ where
2381
+ Self: Sized,
2382
+ F: FnMut(B, Self::Item) -> B,
2383
+ {
2384
+ self.inner.fold(init, |acc, (_, v)| f(acc, v))
2385
+ }
2346
2386
}
2347
2387
#[stable(feature = "rust1", since = "1.0.0")]
2348
2388
impl<K, V> ExactSizeIterator for Values<'_, K, V> {
@@ -2366,6 +2406,14 @@ impl<'a, K, V> Iterator for ValuesMut<'a, K, V> {
2366
2406
fn size_hint(&self) -> (usize, Option<usize>) {
2367
2407
self.inner.size_hint()
2368
2408
}
2409
+ #[inline]
2410
+ fn fold<B, F>(self, init: B, mut f: F) -> B
2411
+ where
2412
+ Self: Sized,
2413
+ F: FnMut(B, Self::Item) -> B,
2414
+ {
2415
+ self.inner.fold(init, |acc, (_, v)| f(acc, v))
2416
+ }
2369
2417
}
2370
2418
#[stable(feature = "map_values_mut", since = "1.10.0")]
2371
2419
impl<K, V> ExactSizeIterator for ValuesMut<'_, K, V> {
@@ -2396,6 +2444,14 @@ impl<K, V> Iterator for IntoKeys<K, V> {
2396
2444
fn size_hint(&self) -> (usize, Option<usize>) {
2397
2445
self.inner.size_hint()
2398
2446
}
2447
+ #[inline]
2448
+ fn fold<B, F>(self, init: B, mut f: F) -> B
2449
+ where
2450
+ Self: Sized,
2451
+ F: FnMut(B, Self::Item) -> B,
2452
+ {
2453
+ self.inner.fold(init, |acc, (k, _)| f(acc, k))
2454
+ }
2399
2455
}
2400
2456
#[stable(feature = "map_into_keys_values", since = "1.54.0")]
2401
2457
impl<K, V> ExactSizeIterator for IntoKeys<K, V> {
@@ -2426,6 +2482,14 @@ impl<K, V> Iterator for IntoValues<K, V> {
2426
2482
fn size_hint(&self) -> (usize, Option<usize>) {
2427
2483
self.inner.size_hint()
2428
2484
}
2485
+ #[inline]
2486
+ fn fold<B, F>(self, init: B, mut f: F) -> B
2487
+ where
2488
+ Self: Sized,
2489
+ F: FnMut(B, Self::Item) -> B,
2490
+ {
2491
+ self.inner.fold(init, |acc, (_, v)| f(acc, v))
2492
+ }
2429
2493
}
2430
2494
#[stable(feature = "map_into_keys_values", since = "1.54.0")]
2431
2495
impl<K, V> ExactSizeIterator for IntoValues<K, V> {
@@ -2456,6 +2520,14 @@ impl<'a, K, V> Iterator for Drain<'a, K, V> {
2456
2520
fn size_hint(&self) -> (usize, Option<usize>) {
2457
2521
self.base.size_hint()
2458
2522
}
2523
+ #[inline]
2524
+ fn fold<B, F>(self, init: B, f: F) -> B
2525
+ where
2526
+ Self: Sized,
2527
+ F: FnMut(B, Self::Item) -> B,
2528
+ {
2529
+ self.base.fold(init, f)
2530
+ }
2459
2531
}
2460
2532
#[stable(feature = "drain", since = "1.6.0")]
2461
2533
impl<K, V> ExactSizeIterator for Drain<'_, K, V> {
0 commit comments