@@ -455,7 +455,7 @@ impl char {
455
455
/// ```
456
456
/// let mut b = [0; 2];
457
457
///
458
- /// let result = 'ß'.encode_utf8 (&mut b).unwrap();
458
+ /// let result = 'ß'.try_encode_utf8 (&mut b).unwrap();
459
459
///
460
460
/// assert_eq!(result, "ß");
461
461
///
@@ -467,7 +467,7 @@ impl char {
467
467
/// ```
468
468
/// let mut b = [0; 1];
469
469
///
470
- /// assert_eq!(None, 'ß'.encode_utf8 (&mut b));
470
+ /// assert_eq!(None, 'ß'.try_encode_utf8 (&mut b));
471
471
/// ```
472
472
#[ unstable( feature = "try_unicode_encode_char" , issue = "52579" ) ]
473
473
#[ inline]
@@ -517,22 +517,17 @@ impl char {
517
517
///
518
518
/// let result = '𝕊'.encode_utf16(&mut b);
519
519
///
520
+ /// assert_eq!(result, "𝕊");
521
+ ///
520
522
/// assert_eq!(result.len(), 2);
521
523
/// ```
522
524
///
523
525
/// A buffer that's too small:
524
526
///
525
527
/// ```
526
- /// use std::thread;
527
- ///
528
- /// let result = thread::spawn(|| {
529
- /// let mut b = [0; 1];
530
- ///
531
- /// // this panics
532
- /// '𝕊'.encode_utf16(&mut b);
533
- /// }).join();
528
+ /// let mut b = [0; 1];
534
529
///
535
- /// assert!(result.is_err( ));
530
+ /// assert_eq!(None, '𝕊'.encode_utf16(&mut b ));
536
531
/// ```
537
532
#[ stable( feature = "unicode_encode_char" , since = "1.15.0" ) ]
538
533
#[ inline]
@@ -556,9 +551,7 @@ impl char {
556
551
/// ```
557
552
/// let mut b = [0; 2];
558
553
///
559
- /// let result = '𝕊'.encode_utf16(&mut b).unwrap();
560
- ///
561
- /// assert_eq!(result, "𝕊");
554
+ /// let result = '𝕊'.try_encode_utf16(&mut b).unwrap();
562
555
///
563
556
/// assert_eq!(result.len(), 2);
564
557
/// ```
@@ -568,7 +561,7 @@ impl char {
568
561
/// ```
569
562
/// let mut b = [0; 1];
570
563
///
571
- /// assert_eq!(None, '𝕊'.encode_utf16 (&mut b));
564
+ /// assert_eq!(None, '𝕊'.try_encode_utf16 (&mut b));
572
565
/// ```
573
566
#[ unstable( feature = "try_unicode_encode_char" , issue = "52579" ) ]
574
567
#[ inline]
0 commit comments