@@ -386,7 +386,13 @@ impl Iterator for EscapeDebug {
386
386
}
387
387
388
388
#[ stable( feature = "char_escape_debug" , since = "1.20.0" ) ]
389
- impl ExactSizeIterator for EscapeDebug { }
389
+ impl ExactSizeIterator for EscapeDebug {
390
+ fn len ( & self ) -> usize {
391
+ let n = self . 0 . len ( ) ;
392
+ debug_assert_eq ! ( self . size_hint( ) , ( n, Some ( n) ) ) ;
393
+ n
394
+ }
395
+ }
390
396
391
397
#[ stable( feature = "fused" , since = "1.26.0" ) ]
392
398
impl FusedIterator for EscapeDebug { }
@@ -430,7 +436,13 @@ impl DoubleEndedIterator for ToLowercase {
430
436
impl FusedIterator for ToLowercase { }
431
437
432
438
#[ stable( feature = "exact_size_case_mapping_iter" , since = "1.35.0" ) ]
433
- impl ExactSizeIterator for ToLowercase { }
439
+ impl ExactSizeIterator for ToLowercase {
440
+ fn len ( & self ) -> usize {
441
+ let n = self . 0 . len ( ) ;
442
+ debug_assert_eq ! ( self . size_hint( ) , ( n, Some ( n) ) ) ;
443
+ n
444
+ }
445
+ }
434
446
435
447
/// Returns an iterator that yields the uppercase equivalent of a `char`.
436
448
///
@@ -464,7 +476,13 @@ impl DoubleEndedIterator for ToUppercase {
464
476
impl FusedIterator for ToUppercase { }
465
477
466
478
#[ stable( feature = "exact_size_case_mapping_iter" , since = "1.35.0" ) ]
467
- impl ExactSizeIterator for ToUppercase { }
479
+ impl ExactSizeIterator for ToUppercase {
480
+ fn len ( & self ) -> usize {
481
+ let n = self . 0 . len ( ) ;
482
+ debug_assert_eq ! ( self . size_hint( ) , ( n, Some ( n) ) ) ;
483
+ n
484
+ }
485
+ }
468
486
469
487
#[ derive( Debug , Clone ) ]
470
488
enum CaseMappingIter {
@@ -509,13 +527,19 @@ impl Iterator for CaseMappingIter {
509
527
}
510
528
511
529
fn size_hint ( & self ) -> ( usize , Option < usize > ) {
512
- let size = match self {
530
+ let size = self . len ( ) ;
531
+ ( size, Some ( size) )
532
+ }
533
+ }
534
+
535
+ impl CaseMappingIter {
536
+ fn len ( & self ) -> usize {
537
+ match self {
513
538
CaseMappingIter :: Three ( ..) => 3 ,
514
539
CaseMappingIter :: Two ( ..) => 2 ,
515
540
CaseMappingIter :: One ( _) => 1 ,
516
541
CaseMappingIter :: Zero => 0 ,
517
- } ;
518
- ( size, Some ( size) )
542
+ }
519
543
}
520
544
}
521
545
0 commit comments