@@ -151,14 +151,9 @@ impl char {
151
151
/// Basic usage:
152
152
///
153
153
/// ```
154
- /// let d = '1';
155
- ///
156
- /// assert!(d.is_digit(10));
157
- ///
158
- /// let d = 'f';
159
- ///
160
- /// assert!(d.is_digit(16));
161
- /// assert!(!d.is_digit(10));
154
+ /// assert!('1'.is_digit(10));
155
+ /// assert!('f'.is_digit(16));
156
+ /// assert!(!'f'.is_digit(10));
162
157
/// ```
163
158
///
164
159
/// Passing a large radix, causing a panic:
@@ -167,10 +162,8 @@ impl char {
167
162
/// use std::thread;
168
163
///
169
164
/// let result = thread::spawn(|| {
170
- /// let d = '1';
171
- ///
172
165
/// // this panics
173
- /// d .is_digit(37);
166
+ /// '1' .is_digit(37);
174
167
/// }).join();
175
168
///
176
169
/// assert!(result.is_err());
@@ -207,25 +200,15 @@ impl char {
207
200
/// Basic usage:
208
201
///
209
202
/// ```
210
- /// let d = '1';
211
- ///
212
- /// assert_eq!(d.to_digit(10), Some(1));
213
- ///
214
- /// let d = 'f';
215
- ///
216
- /// assert_eq!(d.to_digit(16), Some(15));
203
+ /// assert_eq!('1'.to_digit(10), Some(1));
204
+ /// assert_eq!('f'.to_digit(16), Some(15));
217
205
/// ```
218
206
///
219
207
/// Passing a non-digit results in failure:
220
208
///
221
209
/// ```
222
- /// let d = 'f';
223
- ///
224
- /// assert_eq!(d.to_digit(10), None);
225
- ///
226
- /// let d = 'z';
227
- ///
228
- /// assert_eq!(d.to_digit(16), None);
210
+ /// assert_eq!('f'.to_digit(10), None);
211
+ /// assert_eq!('z'.to_digit(16), None);
229
212
/// ```
230
213
///
231
214
/// Passing a large radix, causing a panic:
@@ -234,9 +217,7 @@ impl char {
234
217
/// use std::thread;
235
218
///
236
219
/// let result = thread::spawn(|| {
237
- /// let d = '1';
238
- ///
239
- /// d.to_digit(37);
220
+ /// '1'.to_digit(37);
240
221
/// }).join();
241
222
///
242
223
/// assert!(result.is_err());
@@ -495,12 +476,8 @@ impl char {
495
476
/// Basic usage:
496
477
///
497
478
/// ```
498
- /// let c = 'a';
499
- ///
500
- /// assert!(c.is_alphabetic());
501
- ///
502
- /// let c = '京';
503
- /// assert!(c.is_alphabetic());
479
+ /// assert!('a'.is_alphabetic());
480
+ /// assert!('京'.is_alphabetic());
504
481
///
505
482
/// let c = '💝';
506
483
/// // love is many things, but it is not alphabetic
@@ -554,21 +531,13 @@ impl char {
554
531
/// Basic usage:
555
532
///
556
533
/// ```
557
- /// let c = 'a';
558
- /// assert!(c.is_lowercase());
559
- ///
560
- /// let c = 'δ';
561
- /// assert!(c.is_lowercase());
562
- ///
563
- /// let c = 'A';
564
- /// assert!(!c.is_lowercase());
565
- ///
566
- /// let c = 'Δ';
567
- /// assert!(!c.is_lowercase());
534
+ /// assert!('a'.is_lowercase());
535
+ /// assert!('δ'.is_lowercase());
536
+ /// assert!(!'A'.is_lowercase());
537
+ /// assert!(!'Δ'.is_lowercase());
568
538
///
569
539
/// // The various Chinese scripts do not have case, and so:
570
- /// let c = '中';
571
- /// assert!(!c.is_lowercase());
540
+ /// assert!(!'中'.is_lowercase());
572
541
/// ```
573
542
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
574
543
#[ inline]
@@ -590,21 +559,13 @@ impl char {
590
559
/// Basic usage:
591
560
///
592
561
/// ```
593
- /// let c = 'a';
594
- /// assert!(!c.is_uppercase());
595
- ///
596
- /// let c = 'δ';
597
- /// assert!(!c.is_uppercase());
598
- ///
599
- /// let c = 'A';
600
- /// assert!(c.is_uppercase());
601
- ///
602
- /// let c = 'Δ';
603
- /// assert!(c.is_uppercase());
562
+ /// assert!(!'a'.is_uppercase());
563
+ /// assert!(!'δ'.is_uppercase());
564
+ /// assert!('A'.is_uppercase());
565
+ /// assert!('Δ'.is_uppercase());
604
566
///
605
567
/// // The various Chinese scripts do not have case, and so:
606
- /// let c = '中';
607
- /// assert!(!c.is_uppercase());
568
+ /// assert!(!'中'.is_uppercase());
608
569
/// ```
609
570
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
610
571
#[ inline]
@@ -626,15 +587,12 @@ impl char {
626
587
/// Basic usage:
627
588
///
628
589
/// ```
629
- /// let c = ' ';
630
- /// assert!(c.is_whitespace());
590
+ /// assert!(' '.is_whitespace());
631
591
///
632
592
/// // a non-breaking space
633
- /// let c = '\u{A0}';
634
- /// assert!(c.is_whitespace());
593
+ /// assert!('\u{A0}'.is_whitespace());
635
594
///
636
- /// let c = '越';
637
- /// assert!(!c.is_whitespace());
595
+ /// assert!(!'越'.is_whitespace());
638
596
/// ```
639
597
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
640
598
#[ inline]
@@ -656,29 +614,14 @@ impl char {
656
614
/// Basic usage:
657
615
///
658
616
/// ```
659
- /// let c = '٣';
660
- /// assert!(c.is_alphanumeric());
661
- ///
662
- /// let c = '7';
663
- /// assert!(c.is_alphanumeric());
664
- ///
665
- /// let c = '৬';
666
- /// assert!(c.is_alphanumeric());
667
- ///
668
- /// let c = 'K';
669
- /// assert!(c.is_alphanumeric());
670
- ///
671
- /// let c = 'و';
672
- /// assert!(c.is_alphanumeric());
673
- ///
674
- /// let c = '藏';
675
- /// assert!(c.is_alphanumeric());
676
- ///
677
- /// let c = '¾';
678
- /// assert!(!c.is_alphanumeric());
679
- ///
680
- /// let c = '①';
681
- /// assert!(!c.is_alphanumeric());
617
+ /// assert!('٣'.is_alphanumeric());
618
+ /// assert!('7'.is_alphanumeric());
619
+ /// assert!('৬'.is_alphanumeric());
620
+ /// assert!('K'.is_alphanumeric());
621
+ /// assert!('و'.is_alphanumeric());
622
+ /// assert!('藏'.is_alphanumeric());
623
+ /// assert!(!'¾'.is_alphanumeric());
624
+ /// assert!(!'①'.is_alphanumeric());
682
625
/// ```
683
626
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
684
627
#[ inline]
@@ -697,11 +640,8 @@ impl char {
697
640
///
698
641
/// ```
699
642
/// // U+009C, STRING TERMINATOR
700
- /// let c = '';
701
- /// assert!(c.is_control());
702
- ///
703
- /// let c = 'q';
704
- /// assert!(!c.is_control());
643
+ /// assert!(''.is_control());
644
+ /// assert!(!'q'.is_control());
705
645
/// ```
706
646
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
707
647
#[ inline]
@@ -719,29 +659,14 @@ impl char {
719
659
/// Basic usage:
720
660
///
721
661
/// ```
722
- /// let c = '٣';
723
- /// assert!(c.is_numeric());
724
- ///
725
- /// let c = '7';
726
- /// assert!(c.is_numeric());
727
- ///
728
- /// let c = '৬';
729
- /// assert!(c.is_numeric());
730
- ///
731
- /// let c = 'K';
732
- /// assert!(!c.is_numeric());
733
- ///
734
- /// let c = 'و';
735
- /// assert!(!c.is_numeric());
736
- ///
737
- /// let c = '藏';
738
- /// assert!(!c.is_numeric());
739
- ///
740
- /// let c = '¾';
741
- /// assert!(!c.is_numeric());
742
- ///
743
- /// let c = '①';
744
- /// assert!(!c.is_numeric());
662
+ /// assert!('٣'.is_numeric());
663
+ /// assert!('7'.is_numeric());
664
+ /// assert!('৬'.is_numeric());
665
+ /// assert!(!'K'.is_numeric());
666
+ /// assert!(!'و'.is_numeric());
667
+ /// assert!(!'藏'.is_numeric());
668
+ /// assert!(!'¾'.is_numeric());
669
+ /// assert!(!'①'.is_numeric());
745
670
/// ```
746
671
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
747
672
#[ inline]
@@ -776,13 +701,10 @@ impl char {
776
701
/// Basic usage:
777
702
///
778
703
/// ```
779
- /// let c = 'C';
780
- ///
781
- /// assert_eq!(c.to_lowercase().next(), Some('c'));
704
+ /// assert_eq!('C'.to_lowercase().next(), Some('c'));
782
705
///
783
706
/// // Japanese scripts do not have case, and so:
784
- /// let c = '山';
785
- /// assert_eq!(c.to_lowercase().next(), Some('山'));
707
+ /// assert_eq!('山'.to_lowercase().next(), Some('山'));
786
708
/// ```
787
709
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
788
710
#[ inline]
@@ -813,12 +735,10 @@ impl char {
813
735
/// Basic usage:
814
736
///
815
737
/// ```
816
- /// let c = 'c';
817
- /// assert_eq!(c.to_uppercase().next(), Some('C'));
738
+ /// assert_eq!('c'.to_uppercase().next(), Some('C'));
818
739
///
819
740
/// // Japanese does not have case, and so:
820
- /// let c = '山';
821
- /// assert_eq!(c.to_uppercase().next(), Some('山'));
741
+ /// assert_eq!('山'.to_uppercase().next(), Some('山'));
822
742
/// ```
823
743
///
824
744
/// In Turkish, the equivalent of 'i' in Latin has five forms instead of two:
@@ -829,19 +749,15 @@ impl char {
829
749
/// Note that the lowercase dotted 'i' is the same as the Latin. Therefore:
830
750
///
831
751
/// ```
832
- /// let i = 'i';
833
- ///
834
- /// let upper_i = i.to_uppercase().next();
752
+ /// let upper_i = 'i'.to_uppercase().next();
835
753
/// ```
836
754
///
837
755
/// The value of `upper_i` here relies on the language of the text: if we're
838
756
/// in `en-US`, it should be `Some('I')`, but if we're in `tr_TR`, it should
839
757
/// be `Some('İ')`. `to_uppercase()` does not take this into account, and so:
840
758
///
841
759
/// ```
842
- /// let i = 'i';
843
- ///
844
- /// let upper_i = i.to_uppercase().next();
760
+ /// let upper_i = 'i'.to_uppercase().next();
845
761
///
846
762
/// assert_eq!(Some('I'), upper_i);
847
763
/// ```
0 commit comments