Skip to content

Commit 887e927

Browse files
committed
Rollup merge of rust-lang#32440 - tshepang:compact, r=steveklabnik
doc: remove needless bindings The extra syntax is more noise than help in simple examples like this
2 parents f886939 + 2c48214 commit 887e927

File tree

1 file changed

+48
-132
lines changed

1 file changed

+48
-132
lines changed

src/librustc_unicode/char.rs

+48-132
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,9 @@ impl char {
153153
/// Basic usage:
154154
///
155155
/// ```
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));
164159
/// ```
165160
///
166161
/// Passing a large radix, causing a panic:
@@ -169,10 +164,8 @@ impl char {
169164
/// use std::thread;
170165
///
171166
/// let result = thread::spawn(|| {
172-
/// let d = '1';
173-
///
174167
/// // this panics
175-
/// d.is_digit(37);
168+
/// '1'.is_digit(37);
176169
/// }).join();
177170
///
178171
/// assert!(result.is_err());
@@ -209,25 +202,15 @@ impl char {
209202
/// Basic usage:
210203
///
211204
/// ```
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));
219207
/// ```
220208
///
221209
/// Passing a non-digit results in failure:
222210
///
223211
/// ```
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);
231214
/// ```
232215
///
233216
/// Passing a large radix, causing a panic:
@@ -236,9 +219,7 @@ impl char {
236219
/// use std::thread;
237220
///
238221
/// let result = thread::spawn(|| {
239-
/// let d = '1';
240-
///
241-
/// d.to_digit(37);
222+
/// '1'.to_digit(37);
242223
/// }).join();
243224
///
244225
/// assert!(result.is_err());
@@ -463,12 +444,8 @@ impl char {
463444
/// Basic usage:
464445
///
465446
/// ```
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());
472449
///
473450
/// let c = '💝';
474451
/// // love is many things, but it is not alphabetic
@@ -522,21 +499,13 @@ impl char {
522499
/// Basic usage:
523500
///
524501
/// ```
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());
536506
///
537507
/// // The various Chinese scripts do not have case, and so:
538-
/// let c = '中';
539-
/// assert!(!c.is_lowercase());
508+
/// assert!(!'中'.is_lowercase());
540509
/// ```
541510
#[stable(feature = "rust1", since = "1.0.0")]
542511
#[inline]
@@ -558,21 +527,13 @@ impl char {
558527
/// Basic usage:
559528
///
560529
/// ```
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());
572534
///
573535
/// // The various Chinese scripts do not have case, and so:
574-
/// let c = '中';
575-
/// assert!(!c.is_uppercase());
536+
/// assert!(!'中'.is_uppercase());
576537
/// ```
577538
#[stable(feature = "rust1", since = "1.0.0")]
578539
#[inline]
@@ -594,15 +555,12 @@ impl char {
594555
/// Basic usage:
595556
///
596557
/// ```
597-
/// let c = ' ';
598-
/// assert!(c.is_whitespace());
558+
/// assert!(' '.is_whitespace());
599559
///
600560
/// // a non-breaking space
601-
/// let c = '\u{A0}';
602-
/// assert!(c.is_whitespace());
561+
/// assert!('\u{A0}'.is_whitespace());
603562
///
604-
/// let c = '越';
605-
/// assert!(!c.is_whitespace());
563+
/// assert!(!'越'.is_whitespace());
606564
/// ```
607565
#[stable(feature = "rust1", since = "1.0.0")]
608566
#[inline]
@@ -624,29 +582,14 @@ impl char {
624582
/// Basic usage:
625583
///
626584
/// ```
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());
650593
/// ```
651594
#[stable(feature = "rust1", since = "1.0.0")]
652595
#[inline]
@@ -665,11 +608,8 @@ impl char {
665608
///
666609
/// ```
667610
/// // 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());
673613
/// ```
674614
#[stable(feature = "rust1", since = "1.0.0")]
675615
#[inline]
@@ -687,29 +627,14 @@ impl char {
687627
/// Basic usage:
688628
///
689629
/// ```
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());
713638
/// ```
714639
#[stable(feature = "rust1", since = "1.0.0")]
715640
#[inline]
@@ -744,13 +669,10 @@ impl char {
744669
/// Basic usage:
745670
///
746671
/// ```
747-
/// let c = 'C';
748-
///
749-
/// assert_eq!(c.to_lowercase().next(), Some('c'));
672+
/// assert_eq!('C'.to_lowercase().next(), Some('c'));
750673
///
751674
/// // 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('山'));
754676
/// ```
755677
#[stable(feature = "rust1", since = "1.0.0")]
756678
#[inline]
@@ -781,12 +703,10 @@ impl char {
781703
/// Basic usage:
782704
///
783705
/// ```
784-
/// let c = 'c';
785-
/// assert_eq!(c.to_uppercase().next(), Some('C'));
706+
/// assert_eq!('c'.to_uppercase().next(), Some('C'));
786707
///
787708
/// // 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('山'));
790710
/// ```
791711
///
792712
/// In Turkish, the equivalent of 'i' in Latin has five forms instead of two:
@@ -797,19 +717,15 @@ impl char {
797717
/// Note that the lowercase dotted 'i' is the same as the Latin. Therefore:
798718
///
799719
/// ```
800-
/// let i = 'i';
801-
///
802-
/// let upper_i = i.to_uppercase().next();
720+
/// let upper_i = 'i'.to_uppercase().next();
803721
/// ```
804722
///
805723
/// The value of `upper_i` here relies on the language of the text: if we're
806724
/// in `en-US`, it should be `Some('I')`, but if we're in `tr_TR`, it should
807725
/// be `Some('İ')`. `to_uppercase()` does not take this into account, and so:
808726
///
809727
/// ```
810-
/// let i = 'i';
811-
///
812-
/// let upper_i = i.to_uppercase().next();
728+
/// let upper_i = 'i'.to_uppercase().next();
813729
///
814730
/// assert_eq!(Some('I'), upper_i);
815731
/// ```

0 commit comments

Comments
 (0)