@@ -159,7 +159,7 @@ impl String {
159
159
160
160
if i > 0 {
161
161
unsafe {
162
- res. push_bytes ( v. slice_to ( i) )
162
+ res. as_mut_vec ( ) . push_all ( v. slice_to ( i) )
163
163
} ;
164
164
}
165
165
@@ -176,10 +176,10 @@ impl String {
176
176
macro_rules! error( ( ) => ( {
177
177
unsafe {
178
178
if subseqidx != i_ {
179
- res. push_bytes ( v. slice( subseqidx, i_) ) ;
179
+ res. as_mut_vec ( ) . push_all ( v. slice( subseqidx, i_) ) ;
180
180
}
181
181
subseqidx = i;
182
- res. push_bytes ( REPLACEMENT ) ;
182
+ res. as_mut_vec ( ) . push_all ( REPLACEMENT ) ;
183
183
}
184
184
} ) )
185
185
@@ -245,7 +245,7 @@ impl String {
245
245
}
246
246
if subseqidx < total {
247
247
unsafe {
248
- res. push_bytes ( v. slice ( subseqidx, total) )
248
+ res. as_mut_vec ( ) . push_all ( v. slice ( subseqidx, total) )
249
249
} ;
250
250
}
251
251
Owned ( res. into_string ( ) )
@@ -271,7 +271,7 @@ impl String {
271
271
let mut s = String :: with_capacity ( v. len ( ) / 2 ) ;
272
272
for c in str:: utf16_items ( v) {
273
273
match c {
274
- str:: ScalarValue ( c) => s. push_char ( c) ,
274
+ str:: ScalarValue ( c) => s. push ( c) ,
275
275
str:: LoneSurrogate ( _) => return None
276
276
}
277
277
}
@@ -332,6 +332,7 @@ impl String {
332
332
/// # Example
333
333
///
334
334
/// ```
335
+ /// # #![allow(deprecated)]
335
336
/// let s = String::from_str("hello");
336
337
/// let big = s.append(" ").append("world").append("!");
337
338
/// // s has now been moved and cannot be used
@@ -362,11 +363,11 @@ impl String {
362
363
}
363
364
364
365
let mut buf = String :: new ( ) ;
365
- buf. push_char ( ch) ;
366
+ buf. push ( ch) ;
366
367
let size = buf. len ( ) * length;
367
368
buf. reserve ( size) ;
368
369
for _ in range ( 1 , length) {
369
- buf. push_char ( ch)
370
+ buf. push ( ch)
370
371
}
371
372
buf
372
373
}
@@ -380,6 +381,7 @@ impl String {
380
381
/// # Example
381
382
///
382
383
/// ```rust
384
+ /// # #![allow(deprecated)]
383
385
/// let s = String::from_byte(104);
384
386
/// assert_eq!(s.as_slice(), "h");
385
387
/// ```
@@ -417,7 +419,7 @@ impl String {
417
419
#[ unstable = "duplicate of iterator-based functionality" ]
418
420
pub fn grow ( & mut self , count : uint , ch : char ) {
419
421
for _ in range ( 0 , count) {
420
- self . push_char ( ch)
422
+ self . push ( ch)
421
423
}
422
424
}
423
425
@@ -426,6 +428,7 @@ impl String {
426
428
/// # Example
427
429
///
428
430
/// ```
431
+ /// # #![allow(deprecated)]
429
432
/// let s = String::with_capacity(10);
430
433
/// assert!(s.byte_capacity() >= 10);
431
434
/// ```
@@ -441,7 +444,7 @@ impl String {
441
444
///
442
445
/// ```
443
446
/// let s = String::with_capacity(10);
444
- /// assert!(s.byte_capacity () >= 10);
447
+ /// assert!(s.capacity () >= 10);
445
448
/// ```
446
449
#[ inline]
447
450
#[ unstable = "just implemented, needs to prove itself" ]
@@ -455,9 +458,9 @@ impl String {
455
458
///
456
459
/// ```
457
460
/// let mut s = String::with_capacity(10);
458
- /// let before = s.byte_capacity ();
461
+ /// let before = s.capacity ();
459
462
/// s.reserve_additional(100);
460
- /// assert!(s.byte_capacity () - before >= 100);
463
+ /// assert!(s.capacity () - before >= 100);
461
464
/// ```
462
465
#[ inline]
463
466
pub fn reserve_additional ( & mut self , extra : uint ) {
@@ -471,7 +474,7 @@ impl String {
471
474
/// ```
472
475
/// let mut s = String::new();
473
476
/// s.reserve(10);
474
- /// assert!(s.byte_capacity () >= 10);
477
+ /// assert!(s.capacity () >= 10);
475
478
/// ```
476
479
#[ inline]
477
480
pub fn reserve ( & mut self , capacity : uint ) {
@@ -485,7 +488,7 @@ impl String {
485
488
/// ```
486
489
/// let mut s = String::new();
487
490
/// s.reserve_exact(10);
488
- /// assert_eq!(s.byte_capacity (), 10);
491
+ /// assert_eq!(s.capacity (), 10);
489
492
/// ```
490
493
#[ inline]
491
494
pub fn reserve_exact ( & mut self , capacity : uint ) {
@@ -499,9 +502,9 @@ impl String {
499
502
/// ```
500
503
/// let mut s = String::from_str("foo");
501
504
/// s.reserve(100);
502
- /// assert!(s.byte_capacity () >= 100);
505
+ /// assert!(s.capacity () >= 100);
503
506
/// s.shrink_to_fit();
504
- /// assert_eq!(s.byte_capacity (), 3);
507
+ /// assert_eq!(s.capacity (), 3);
505
508
/// ```
506
509
#[ inline]
507
510
pub fn shrink_to_fit ( & mut self ) {
@@ -527,7 +530,7 @@ impl String {
527
530
/// assert_eq!(s.as_slice(), "abc123");
528
531
/// ```
529
532
#[ inline]
530
- #[ stable = "function just renamed from push_char " ]
533
+ #[ stable = "function just renamed from push " ]
531
534
pub fn push ( & mut self , ch : char ) {
532
535
let cur_len = self . len ( ) ;
533
536
// This may use up to 4 bytes.
@@ -552,6 +555,7 @@ impl String {
552
555
/// # Example
553
556
///
554
557
/// ```
558
+ /// # #![allow(deprecated)]
555
559
/// let mut s = String::new();
556
560
/// unsafe {
557
561
/// s.push_bytes([104, 101, 108, 108, 111]);
@@ -587,6 +591,7 @@ impl String {
587
591
/// # Example
588
592
///
589
593
/// ```
594
+ /// # #![allow(deprecated)]
590
595
/// let mut s = String::from_str("hello");
591
596
/// unsafe {
592
597
/// let bytes = s.as_mut_bytes();
@@ -598,7 +603,7 @@ impl String {
598
603
/// assert_eq!(s.as_slice(), "h3ll0")
599
604
/// ```
600
605
#[ inline]
601
- #[ deprecated = "call .as_mut_vec().as_slice () instead" ]
606
+ #[ deprecated = "call .as_mut_vec().as_mut_slice () instead" ]
602
607
pub unsafe fn as_mut_bytes < ' a > ( & ' a mut self ) -> & ' a mut [ u8 ] {
603
608
self . vec . as_mut_slice ( )
604
609
}
@@ -631,6 +636,7 @@ impl String {
631
636
/// # Example
632
637
///
633
638
/// ```
639
+ /// # #![allow(deprecated)]
634
640
/// let mut s = String::from_str("hell");
635
641
/// unsafe {
636
642
/// s.push_byte(111);
@@ -652,6 +658,7 @@ impl String {
652
658
/// # Example
653
659
///
654
660
/// ```
661
+ /// # #![allow(deprecated)]
655
662
/// let mut s = String::from_str("foo");
656
663
/// unsafe {
657
664
/// assert_eq!(s.pop_byte(), Some(111));
@@ -714,6 +721,7 @@ impl String {
714
721
/// # Example
715
722
///
716
723
/// ```
724
+ /// # #![allow(deprecated)]
717
725
/// let mut s = String::from_str("foo");
718
726
/// unsafe {
719
727
/// assert_eq!(s.shift_byte(), Some(102));
@@ -722,7 +730,7 @@ impl String {
722
730
/// assert_eq!(s.shift_byte(), None);
723
731
/// }
724
732
/// ```
725
- #[ deprecated = "call .as_mut_rev ().remove(0)" ]
733
+ #[ deprecated = "call .as_mut_vec ().remove(0)" ]
726
734
pub unsafe fn shift_byte ( & mut self ) -> Option < u8 > {
727
735
self . vec . remove ( 0 )
728
736
}
@@ -782,6 +790,7 @@ impl String {
782
790
///
783
791
/// If `idx` does not lie on a character boundary or is out of bounds, then
784
792
/// this function will fail.
793
+ #[ unstable = "the failure semantics of this function are uncertain" ]
785
794
pub fn insert ( & mut self , idx : uint , ch : char ) {
786
795
let len = self . len ( ) ;
787
796
assert ! ( idx <= len) ;
@@ -854,7 +863,7 @@ impl FromIterator<char> for String {
854
863
impl Extendable < char > for String {
855
864
fn extend < I : Iterator < char > > ( & mut self , mut iterator : I ) {
856
865
for ch in iterator {
857
- self . push_char ( ch)
866
+ self . push ( ch)
858
867
}
859
868
}
860
869
}
@@ -1171,13 +1180,13 @@ mod tests {
1171
1180
}
1172
1181
1173
1182
#[ test]
1174
- fn test_push_char ( ) {
1183
+ fn test_push ( ) {
1175
1184
let mut data = String :: from_str ( "ประเทศไทย中" ) ;
1176
- data. push_char ( '华' ) ;
1177
- data. push_char ( 'b' ) ; // 1 byte
1178
- data. push_char ( '¢' ) ; // 2 byte
1179
- data. push_char ( '€' ) ; // 3 byte
1180
- data. push_char ( '𤭢' ) ; // 4 byte
1185
+ data. push ( '华' ) ;
1186
+ data. push ( 'b' ) ; // 1 byte
1187
+ data. push ( '¢' ) ; // 2 byte
1188
+ data. push ( '€' ) ; // 3 byte
1189
+ data. push ( '𤭢' ) ; // 4 byte
1181
1190
assert_eq ! ( data. as_slice( ) , "ประเทศไทย中华b¢€𤭢" ) ;
1182
1191
}
1183
1192
0 commit comments