@@ -153,14 +153,9 @@ impl char {
153
153
/// Basic usage:
154
154
///
155
155
/// ```
156
- /// let d = '1';
157
- ///
158
- /// assert!(d.is_digit(10));
159
- ///
160
- /// let d = 'f';
161
- ///
162
- /// assert!(d.is_digit(16));
163
- /// assert!(!d.is_digit(10));
156
+ /// assert!('1'.is_digit(10));
157
+ /// assert!('f'.is_digit(16));
158
+ /// assert!(!'f'.is_digit(10));
164
159
/// ```
165
160
///
166
161
/// Passing a large radix, causing a panic:
@@ -169,10 +164,8 @@ impl char {
169
164
/// use std::thread;
170
165
///
171
166
/// let result = thread::spawn(|| {
172
- /// let d = '1';
173
- ///
174
167
/// // this panics
175
- /// d .is_digit(37);
168
+ /// '1' .is_digit(37);
176
169
/// }).join();
177
170
///
178
171
/// assert!(result.is_err());
@@ -209,25 +202,15 @@ impl char {
209
202
/// Basic usage:
210
203
///
211
204
/// ```
212
- /// let d = '1';
213
- ///
214
- /// assert_eq!(d.to_digit(10), Some(1));
215
- ///
216
- /// let d = 'f';
217
- ///
218
- /// assert_eq!(d.to_digit(16), Some(15));
205
+ /// assert_eq!('1'.to_digit(10), Some(1));
206
+ /// assert_eq!('f'.to_digit(16), Some(15));
219
207
/// ```
220
208
///
221
209
/// Passing a non-digit results in failure:
222
210
///
223
211
/// ```
224
- /// let d = 'f';
225
- ///
226
- /// assert_eq!(d.to_digit(10), None);
227
- ///
228
- /// let d = 'z';
229
- ///
230
- /// assert_eq!(d.to_digit(16), None);
212
+ /// assert_eq!('f'.to_digit(10), None);
213
+ /// assert_eq!('z'.to_digit(16), None);
231
214
/// ```
232
215
///
233
216
/// Passing a large radix, causing a panic:
@@ -236,9 +219,7 @@ impl char {
236
219
/// use std::thread;
237
220
///
238
221
/// let result = thread::spawn(|| {
239
- /// let d = '1';
240
- ///
241
- /// d.to_digit(37);
222
+ /// '1'.to_digit(37);
242
223
/// }).join();
243
224
///
244
225
/// assert!(result.is_err());
@@ -463,12 +444,8 @@ impl char {
463
444
/// Basic usage:
464
445
///
465
446
/// ```
466
- /// let c = 'a';
467
- ///
468
- /// assert!(c.is_alphabetic());
469
- ///
470
- /// let c = '京';
471
- /// assert!(c.is_alphabetic());
447
+ /// assert!('a'.is_alphabetic());
448
+ /// assert!('京'.is_alphabetic());
472
449
///
473
450
/// let c = '💝';
474
451
/// // love is many things, but it is not alphabetic
@@ -522,21 +499,13 @@ impl char {
522
499
/// Basic usage:
523
500
///
524
501
/// ```
525
- /// let c = 'a';
526
- /// assert!(c.is_lowercase());
527
- ///
528
- /// let c = 'δ';
529
- /// assert!(c.is_lowercase());
530
- ///
531
- /// let c = 'A';
532
- /// assert!(!c.is_lowercase());
533
- ///
534
- /// let c = 'Δ';
535
- /// assert!(!c.is_lowercase());
502
+ /// assert!('a'.is_lowercase());
503
+ /// assert!('δ'.is_lowercase());
504
+ /// assert!(!'A'.is_lowercase());
505
+ /// assert!(!'Δ'.is_lowercase());
536
506
///
537
507
/// // The various Chinese scripts do not have case, and so:
538
- /// let c = '中';
539
- /// assert!(!c.is_lowercase());
508
+ /// assert!(!'中'.is_lowercase());
540
509
/// ```
541
510
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
542
511
#[ inline]
@@ -558,21 +527,13 @@ impl char {
558
527
/// Basic usage:
559
528
///
560
529
/// ```
561
- /// let c = 'a';
562
- /// assert!(!c.is_uppercase());
563
- ///
564
- /// let c = 'δ';
565
- /// assert!(!c.is_uppercase());
566
- ///
567
- /// let c = 'A';
568
- /// assert!(c.is_uppercase());
569
- ///
570
- /// let c = 'Δ';
571
- /// assert!(c.is_uppercase());
530
+ /// assert!(!'a'.is_uppercase());
531
+ /// assert!(!'δ'.is_uppercase());
532
+ /// assert!('A'.is_uppercase());
533
+ /// assert!('Δ'.is_uppercase());
572
534
///
573
535
/// // The various Chinese scripts do not have case, and so:
574
- /// let c = '中';
575
- /// assert!(!c.is_uppercase());
536
+ /// assert!(!'中'.is_uppercase());
576
537
/// ```
577
538
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
578
539
#[ inline]
@@ -594,15 +555,12 @@ impl char {
594
555
/// Basic usage:
595
556
///
596
557
/// ```
597
- /// let c = ' ';
598
- /// assert!(c.is_whitespace());
558
+ /// assert!(' '.is_whitespace());
599
559
///
600
560
/// // a non-breaking space
601
- /// let c = '\u{A0}';
602
- /// assert!(c.is_whitespace());
561
+ /// assert!('\u{A0}'.is_whitespace());
603
562
///
604
- /// let c = '越';
605
- /// assert!(!c.is_whitespace());
563
+ /// assert!(!'越'.is_whitespace());
606
564
/// ```
607
565
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
608
566
#[ inline]
@@ -624,29 +582,14 @@ impl char {
624
582
/// Basic usage:
625
583
///
626
584
/// ```
627
- /// let c = '٣';
628
- /// assert!(c.is_alphanumeric());
629
- ///
630
- /// let c = '7';
631
- /// assert!(c.is_alphanumeric());
632
- ///
633
- /// let c = '৬';
634
- /// assert!(c.is_alphanumeric());
635
- ///
636
- /// let c = 'K';
637
- /// assert!(c.is_alphanumeric());
638
- ///
639
- /// let c = 'و';
640
- /// assert!(c.is_alphanumeric());
641
- ///
642
- /// let c = '藏';
643
- /// assert!(c.is_alphanumeric());
644
- ///
645
- /// let c = '¾';
646
- /// assert!(!c.is_alphanumeric());
647
- ///
648
- /// let c = '①';
649
- /// assert!(!c.is_alphanumeric());
585
+ /// assert!('٣'.is_alphanumeric());
586
+ /// assert!('7'.is_alphanumeric());
587
+ /// assert!('৬'.is_alphanumeric());
588
+ /// assert!('K'.is_alphanumeric());
589
+ /// assert!('و'.is_alphanumeric());
590
+ /// assert!('藏'.is_alphanumeric());
591
+ /// assert!(!'¾'.is_alphanumeric());
592
+ /// assert!(!'①'.is_alphanumeric());
650
593
/// ```
651
594
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
652
595
#[ inline]
@@ -665,11 +608,8 @@ impl char {
665
608
///
666
609
/// ```
667
610
/// // U+009C, STRING TERMINATOR
668
- /// let c = '';
669
- /// assert!(c.is_control());
670
- ///
671
- /// let c = 'q';
672
- /// assert!(!c.is_control());
611
+ /// assert!(''.is_control());
612
+ /// assert!(!'q'.is_control());
673
613
/// ```
674
614
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
675
615
#[ inline]
@@ -687,29 +627,14 @@ impl char {
687
627
/// Basic usage:
688
628
///
689
629
/// ```
690
- /// let c = '٣';
691
- /// assert!(c.is_numeric());
692
- ///
693
- /// let c = '7';
694
- /// assert!(c.is_numeric());
695
- ///
696
- /// let c = '৬';
697
- /// assert!(c.is_numeric());
698
- ///
699
- /// let c = 'K';
700
- /// assert!(!c.is_numeric());
701
- ///
702
- /// let c = 'و';
703
- /// assert!(!c.is_numeric());
704
- ///
705
- /// let c = '藏';
706
- /// assert!(!c.is_numeric());
707
- ///
708
- /// let c = '¾';
709
- /// assert!(!c.is_numeric());
710
- ///
711
- /// let c = '①';
712
- /// assert!(!c.is_numeric());
630
+ /// assert!('٣'.is_numeric());
631
+ /// assert!('7'.is_numeric());
632
+ /// assert!('৬'.is_numeric());
633
+ /// assert!(!'K'.is_numeric());
634
+ /// assert!(!'و'.is_numeric());
635
+ /// assert!(!'藏'.is_numeric());
636
+ /// assert!(!'¾'.is_numeric());
637
+ /// assert!(!'①'.is_numeric());
713
638
/// ```
714
639
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
715
640
#[ inline]
@@ -744,13 +669,10 @@ impl char {
744
669
/// Basic usage:
745
670
///
746
671
/// ```
747
- /// let c = 'C';
748
- ///
749
- /// assert_eq!(c.to_lowercase().next(), Some('c'));
672
+ /// assert_eq!('C'.to_lowercase().next(), Some('c'));
750
673
///
751
674
/// // Japanese scripts do not have case, and so:
752
- /// let c = '山';
753
- /// assert_eq!(c.to_lowercase().next(), Some('山'));
675
+ /// assert_eq!('山'.to_lowercase().next(), Some('山'));
754
676
/// ```
755
677
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
756
678
#[ inline]
@@ -781,12 +703,10 @@ impl char {
781
703
/// Basic usage:
782
704
///
783
705
/// ```
784
- /// let c = 'c';
785
- /// assert_eq!(c.to_uppercase().next(), Some('C'));
706
+ /// assert_eq!('c'.to_uppercase().next(), Some('C'));
786
707
///
787
708
/// // Japanese does not have case, and so:
788
- /// let c = '山';
789
- /// assert_eq!(c.to_uppercase().next(), Some('山'));
709
+ /// assert_eq!('山'.to_uppercase().next(), Some('山'));
790
710
/// ```
791
711
///
792
712
/// In Turkish, the equivalent of 'i' in Latin has five forms instead of two:
@@ -797,19 +717,15 @@ impl char {
797
717
/// Note that the lowercase dotted 'i' is the same as the Latin. Therefore:
798
718
///
799
719
/// ```
800
- /// let i = 'i';
801
- ///
802
- /// let upper_i = i.to_uppercase().next();
720
+ /// let upper_i = 'i'.to_uppercase().next();
803
721
/// ```
804
722
///
805
723
/// The value of `upper_i` here relies on the language of the text: if we're
806
724
/// in `en-US`, it should be `Some('I')`, but if we're in `tr_TR`, it should
807
725
/// be `Some('İ')`. `to_uppercase()` does not take this into account, and so:
808
726
///
809
727
/// ```
810
- /// let i = 'i';
811
- ///
812
- /// let upper_i = i.to_uppercase().next();
728
+ /// let upper_i = 'i'.to_uppercase().next();
813
729
///
814
730
/// assert_eq!(Some('I'), upper_i);
815
731
/// ```
0 commit comments