@@ -112,11 +112,6 @@ impl<S: Borrow<str>> SliceConcatExt<str> for [S] {
112
112
}
113
113
}
114
114
115
- /// Deprecated, renamed to EncodeUtf16
116
- #[ unstable( feature = "str_utf16" , issue = "27714" ) ]
117
- #[ rustc_deprecated( since = "1.8.0" , reason = "renamed to EncodeUtf16" ) ]
118
- pub type Utf16Units < ' a > = EncodeUtf16 < ' a > ;
119
-
120
115
/// External iterator for a string's UTF-16 code units.
121
116
///
122
117
/// For use with the `std::iter` module.
@@ -352,230 +347,6 @@ impl str {
352
347
core_str:: StrExt :: slice_mut_unchecked ( self , begin, end)
353
348
}
354
349
355
- /// Given a byte position, returns the next `char` and its index.
356
- ///
357
- /// # Panics
358
- ///
359
- /// If `i` is greater than or equal to the length of the string.
360
- /// If `i` is not the index of the beginning of a valid UTF-8 sequence.
361
- ///
362
- /// # Examples
363
- ///
364
- /// This example manually iterates through the code points of a string;
365
- /// this should normally be
366
- /// done by `.chars()` or `.char_indices()`.
367
- ///
368
- /// ```
369
- /// #![feature(str_char)]
370
- /// #![allow(deprecated)]
371
- ///
372
- /// use std::str::CharRange;
373
- ///
374
- /// let s = "中华Việt Nam";
375
- /// let mut i = 0;
376
- /// while i < s.len() {
377
- /// let CharRange {ch, next} = s.char_range_at(i);
378
- /// println!("{}: {}", i, ch);
379
- /// i = next;
380
- /// }
381
- /// ```
382
- ///
383
- /// This outputs:
384
- ///
385
- /// ```text
386
- /// 0: 中
387
- /// 3: 华
388
- /// 6: V
389
- /// 7: i
390
- /// 8: e
391
- /// 9:
392
- /// 11:
393
- /// 13: t
394
- /// 14:
395
- /// 15: N
396
- /// 16: a
397
- /// 17: m
398
- /// ```
399
- #[ unstable( feature = "str_char" ,
400
- reason = "often replaced by char_indices, this method may \
401
- be removed in favor of just char_at() or eventually \
402
- removed altogether",
403
- issue = "27754" ) ]
404
- #[ inline]
405
- #[ rustc_deprecated( reason = "use slicing plus chars() plus len_utf8" ,
406
- since = "1.9.0" ) ]
407
- #[ allow( deprecated) ]
408
- pub fn char_range_at ( & self , start : usize ) -> CharRange {
409
- core_str:: StrExt :: char_range_at ( self , start)
410
- }
411
-
412
- /// Given a byte position, returns the previous `char` and its position.
413
- ///
414
- /// Note that Unicode has many features, such as combining marks, ligatures,
415
- /// and direction marks, that need to be taken into account to correctly reverse a string.
416
- ///
417
- /// Returns 0 for next index if called on start index 0.
418
- ///
419
- /// # Panics
420
- ///
421
- /// If `i` is greater than the length of the string.
422
- /// If `i` is not an index following a valid UTF-8 sequence.
423
- ///
424
- /// # Examples
425
- ///
426
- /// This example manually iterates through the code points of a string;
427
- /// this should normally be
428
- /// done by `.chars().rev()` or `.char_indices()`.
429
- ///
430
- /// ```
431
- /// #![feature(str_char)]
432
- /// #![allow(deprecated)]
433
- ///
434
- /// use std::str::CharRange;
435
- ///
436
- /// let s = "中华Việt Nam";
437
- /// let mut i = s.len();
438
- /// while i > 0 {
439
- /// let CharRange {ch, next} = s.char_range_at_reverse(i);
440
- /// println!("{}: {}", i, ch);
441
- /// i = next;
442
- /// }
443
- /// ```
444
- ///
445
- /// This outputs:
446
- ///
447
- /// ```text
448
- /// 18: m
449
- /// 17: a
450
- /// 16: N
451
- /// 15:
452
- /// 14: t
453
- /// 13:
454
- /// 11:
455
- /// 9: e
456
- /// 8: i
457
- /// 7: V
458
- /// 6: 华
459
- /// 3: 中
460
- /// ```
461
- #[ unstable( feature = "str_char" ,
462
- reason = "often replaced by char_indices, this method may \
463
- be removed in favor of just char_at_reverse() or \
464
- eventually removed altogether",
465
- issue = "27754" ) ]
466
- #[ inline]
467
- #[ rustc_deprecated( reason = "use slicing plus chars().rev() plus len_utf8" ,
468
- since = "1.9.0" ) ]
469
- #[ allow( deprecated) ]
470
- pub fn char_range_at_reverse ( & self , start : usize ) -> CharRange {
471
- core_str:: StrExt :: char_range_at_reverse ( self , start)
472
- }
473
-
474
- /// Given a byte position, returns the `char` at that position.
475
- ///
476
- /// # Panics
477
- ///
478
- /// If `i` is greater than or equal to the length of the string.
479
- /// If `i` is not the index of the beginning of a valid UTF-8 sequence.
480
- ///
481
- /// # Examples
482
- ///
483
- /// ```
484
- /// #![feature(str_char)]
485
- /// #![allow(deprecated)]
486
- ///
487
- /// let s = "abπc";
488
- /// assert_eq!(s.char_at(1), 'b');
489
- /// assert_eq!(s.char_at(2), 'π');
490
- /// assert_eq!(s.char_at(4), 'c');
491
- /// ```
492
- #[ unstable( feature = "str_char" ,
493
- reason = "frequently replaced by the chars() iterator, this \
494
- method may be removed or possibly renamed in the \
495
- future; it is normally replaced by chars/char_indices \
496
- iterators or by getting the first char from a \
497
- subslice",
498
- issue = "27754" ) ]
499
- #[ inline]
500
- #[ allow( deprecated) ]
501
- #[ rustc_deprecated( reason = "use slicing plus chars()" ,
502
- since = "1.9.0" ) ]
503
- pub fn char_at ( & self , i : usize ) -> char {
504
- core_str:: StrExt :: char_at ( self , i)
505
- }
506
-
507
- /// Given a byte position, returns the `char` at that position, counting
508
- /// from the end.
509
- ///
510
- /// # Panics
511
- ///
512
- /// If `i` is greater than the length of the string.
513
- /// If `i` is not an index following a valid UTF-8 sequence.
514
- ///
515
- /// # Examples
516
- ///
517
- /// ```
518
- /// #![feature(str_char)]
519
- /// #![allow(deprecated)]
520
- ///
521
- /// let s = "abπc";
522
- /// assert_eq!(s.char_at_reverse(1), 'a');
523
- /// assert_eq!(s.char_at_reverse(2), 'b');
524
- /// assert_eq!(s.char_at_reverse(3), 'π');
525
- /// ```
526
- #[ unstable( feature = "str_char" ,
527
- reason = "see char_at for more details, but reverse semantics \
528
- are also somewhat unclear, especially with which \
529
- cases generate panics",
530
- issue = "27754" ) ]
531
- #[ inline]
532
- #[ rustc_deprecated( reason = "use slicing plus chars().rev()" ,
533
- since = "1.9.0" ) ]
534
- #[ allow( deprecated) ]
535
- pub fn char_at_reverse ( & self , i : usize ) -> char {
536
- core_str:: StrExt :: char_at_reverse ( self , i)
537
- }
538
-
539
- /// Retrieves the first `char` from a `&str` and returns it.
540
- ///
541
- /// Note that a single Unicode character (grapheme cluster)
542
- /// can be composed of multiple `char`s.
543
- ///
544
- /// This does not allocate a new string; instead, it returns a slice that
545
- /// points one code point beyond the code point that was shifted.
546
- ///
547
- /// `None` is returned if the slice is empty.
548
- ///
549
- /// # Examples
550
- ///
551
- /// ```
552
- /// #![feature(str_char)]
553
- /// #![allow(deprecated)]
554
- ///
555
- /// let s = "Łódź"; // \u{141}o\u{301}dz\u{301}
556
- /// let (c, s1) = s.slice_shift_char().unwrap();
557
- ///
558
- /// assert_eq!(c, 'Ł');
559
- /// assert_eq!(s1, "ódź");
560
- ///
561
- /// let (c, s2) = s1.slice_shift_char().unwrap();
562
- ///
563
- /// assert_eq!(c, 'o');
564
- /// assert_eq!(s2, "\u{301}dz\u{301}");
565
- /// ```
566
- #[ unstable( feature = "str_char" ,
567
- reason = "awaiting conventions about shifting and slices and \
568
- may not be warranted with the existence of the chars \
569
- and/or char_indices iterators",
570
- issue = "27754" ) ]
571
- #[ inline]
572
- #[ rustc_deprecated( reason = "use chars() plus Chars::as_str" ,
573
- since = "1.9.0" ) ]
574
- #[ allow( deprecated) ]
575
- pub fn slice_shift_char ( & self ) -> Option < ( char , & str ) > {
576
- core_str:: StrExt :: slice_shift_char ( self )
577
- }
578
-
579
350
/// Divide one string slice into two at an index.
580
351
///
581
352
/// The argument, `mid`, should be a byte offset from the start of the
@@ -867,16 +638,6 @@ impl str {
867
638
core_str:: StrExt :: lines_any ( self )
868
639
}
869
640
870
- /// Returns an iterator of `u16` over the string encoded as UTF-16.
871
- #[ unstable( feature = "str_utf16" ,
872
- reason = "this functionality may only be provided by libunicode" ,
873
- issue = "27714" ) ]
874
- #[ rustc_deprecated( since = "1.8.0" , reason = "renamed to encode_utf16" ) ]
875
- #[ allow( deprecated) ]
876
- pub fn utf16_units ( & self ) -> Utf16Units {
877
- Utf16Units { encoder : Utf16Encoder :: new ( self [ ..] . chars ( ) ) }
878
- }
879
-
880
641
/// Returns an iterator of `u16` over the string encoded as UTF-16.
881
642
#[ stable( feature = "encode_utf16" , since = "1.8.0" ) ]
882
643
pub fn encode_utf16 ( & self ) -> EncodeUtf16 {
0 commit comments