@@ -159,7 +159,7 @@ impl String {
159159
160160 if i > 0 {
161161 unsafe {
162- res. push_bytes ( v. slice_to ( i) )
162+ res. as_mut_vec ( ) . push_all ( v. slice_to ( i) )
163163 } ;
164164 }
165165
@@ -176,10 +176,10 @@ impl String {
176176 macro_rules! error( ( ) => ( {
177177 unsafe {
178178 if subseqidx != i_ {
179- res. push_bytes ( v. slice( subseqidx, i_) ) ;
179+ res. as_mut_vec ( ) . push_all ( v. slice( subseqidx, i_) ) ;
180180 }
181181 subseqidx = i;
182- res. push_bytes ( REPLACEMENT ) ;
182+ res. as_mut_vec ( ) . push_all ( REPLACEMENT ) ;
183183 }
184184 } ) )
185185
@@ -245,7 +245,7 @@ impl String {
245245 }
246246 if subseqidx < total {
247247 unsafe {
248- res. push_bytes ( v. slice ( subseqidx, total) )
248+ res. as_mut_vec ( ) . push_all ( v. slice ( subseqidx, total) )
249249 } ;
250250 }
251251 Owned ( res. into_string ( ) )
@@ -271,7 +271,7 @@ impl String {
271271 let mut s = String :: with_capacity ( v. len ( ) / 2 ) ;
272272 for c in str:: utf16_items ( v) {
273273 match c {
274- str:: ScalarValue ( c) => s. push_char ( c) ,
274+ str:: ScalarValue ( c) => s. push ( c) ,
275275 str:: LoneSurrogate ( _) => return None
276276 }
277277 }
@@ -332,6 +332,7 @@ impl String {
332332 /// # Example
333333 ///
334334 /// ```
335+ /// # #![allow(deprecated)]
335336 /// let s = String::from_str("hello");
336337 /// let big = s.append(" ").append("world").append("!");
337338 /// // s has now been moved and cannot be used
@@ -362,11 +363,11 @@ impl String {
362363 }
363364
364365 let mut buf = String :: new ( ) ;
365- buf. push_char ( ch) ;
366+ buf. push ( ch) ;
366367 let size = buf. len ( ) * length;
367368 buf. reserve ( size) ;
368369 for _ in range ( 1 , length) {
369- buf. push_char ( ch)
370+ buf. push ( ch)
370371 }
371372 buf
372373 }
@@ -380,6 +381,7 @@ impl String {
380381 /// # Example
381382 ///
382383 /// ```rust
384+ /// # #![allow(deprecated)]
383385 /// let s = String::from_byte(104);
384386 /// assert_eq!(s.as_slice(), "h");
385387 /// ```
@@ -417,7 +419,7 @@ impl String {
417419 #[ unstable = "duplicate of iterator-based functionality" ]
418420 pub fn grow ( & mut self , count : uint , ch : char ) {
419421 for _ in range ( 0 , count) {
420- self . push_char ( ch)
422+ self . push ( ch)
421423 }
422424 }
423425
@@ -426,6 +428,7 @@ impl String {
426428 /// # Example
427429 ///
428430 /// ```
431+ /// # #![allow(deprecated)]
429432 /// let s = String::with_capacity(10);
430433 /// assert!(s.byte_capacity() >= 10);
431434 /// ```
@@ -441,7 +444,7 @@ impl String {
441444 ///
442445 /// ```
443446 /// let s = String::with_capacity(10);
444- /// assert!(s.byte_capacity () >= 10);
447+ /// assert!(s.capacity () >= 10);
445448 /// ```
446449 #[ inline]
447450 #[ unstable = "just implemented, needs to prove itself" ]
@@ -455,9 +458,9 @@ impl String {
455458 ///
456459 /// ```
457460 /// let mut s = String::with_capacity(10);
458- /// let before = s.byte_capacity ();
461+ /// let before = s.capacity ();
459462 /// s.reserve_additional(100);
460- /// assert!(s.byte_capacity () - before >= 100);
463+ /// assert!(s.capacity () - before >= 100);
461464 /// ```
462465 #[ inline]
463466 pub fn reserve_additional ( & mut self , extra : uint ) {
@@ -471,7 +474,7 @@ impl String {
471474 /// ```
472475 /// let mut s = String::new();
473476 /// s.reserve(10);
474- /// assert!(s.byte_capacity () >= 10);
477+ /// assert!(s.capacity () >= 10);
475478 /// ```
476479 #[ inline]
477480 pub fn reserve ( & mut self , capacity : uint ) {
@@ -485,7 +488,7 @@ impl String {
485488 /// ```
486489 /// let mut s = String::new();
487490 /// s.reserve_exact(10);
488- /// assert_eq!(s.byte_capacity (), 10);
491+ /// assert_eq!(s.capacity (), 10);
489492 /// ```
490493 #[ inline]
491494 pub fn reserve_exact ( & mut self , capacity : uint ) {
@@ -499,9 +502,9 @@ impl String {
499502 /// ```
500503 /// let mut s = String::from_str("foo");
501504 /// s.reserve(100);
502- /// assert!(s.byte_capacity () >= 100);
505+ /// assert!(s.capacity () >= 100);
503506 /// s.shrink_to_fit();
504- /// assert_eq!(s.byte_capacity (), 3);
507+ /// assert_eq!(s.capacity (), 3);
505508 /// ```
506509 #[ inline]
507510 pub fn shrink_to_fit ( & mut self ) {
@@ -527,7 +530,7 @@ impl String {
527530 /// assert_eq!(s.as_slice(), "abc123");
528531 /// ```
529532 #[ inline]
530- #[ stable = "function just renamed from push_char " ]
533+ #[ stable = "function just renamed from push " ]
531534 pub fn push ( & mut self , ch : char ) {
532535 let cur_len = self . len ( ) ;
533536 // This may use up to 4 bytes.
@@ -552,6 +555,7 @@ impl String {
552555 /// # Example
553556 ///
554557 /// ```
558+ /// # #![allow(deprecated)]
555559 /// let mut s = String::new();
556560 /// unsafe {
557561 /// s.push_bytes([104, 101, 108, 108, 111]);
@@ -587,6 +591,7 @@ impl String {
587591 /// # Example
588592 ///
589593 /// ```
594+ /// # #![allow(deprecated)]
590595 /// let mut s = String::from_str("hello");
591596 /// unsafe {
592597 /// let bytes = s.as_mut_bytes();
@@ -598,7 +603,7 @@ impl String {
598603 /// assert_eq!(s.as_slice(), "h3ll0")
599604 /// ```
600605 #[ inline]
601- #[ deprecated = "call .as_mut_vec().as_slice () instead" ]
606+ #[ deprecated = "call .as_mut_vec().as_mut_slice () instead" ]
602607 pub unsafe fn as_mut_bytes < ' a > ( & ' a mut self ) -> & ' a mut [ u8 ] {
603608 self . vec . as_mut_slice ( )
604609 }
@@ -631,6 +636,7 @@ impl String {
631636 /// # Example
632637 ///
633638 /// ```
639+ /// # #![allow(deprecated)]
634640 /// let mut s = String::from_str("hell");
635641 /// unsafe {
636642 /// s.push_byte(111);
@@ -652,6 +658,7 @@ impl String {
652658 /// # Example
653659 ///
654660 /// ```
661+ /// # #![allow(deprecated)]
655662 /// let mut s = String::from_str("foo");
656663 /// unsafe {
657664 /// assert_eq!(s.pop_byte(), Some(111));
@@ -714,6 +721,7 @@ impl String {
714721 /// # Example
715722 ///
716723 /// ```
724+ /// # #![allow(deprecated)]
717725 /// let mut s = String::from_str("foo");
718726 /// unsafe {
719727 /// assert_eq!(s.shift_byte(), Some(102));
@@ -722,7 +730,7 @@ impl String {
722730 /// assert_eq!(s.shift_byte(), None);
723731 /// }
724732 /// ```
725- #[ deprecated = "call .as_mut_rev ().remove(0)" ]
733+ #[ deprecated = "call .as_mut_vec ().remove(0)" ]
726734 pub unsafe fn shift_byte ( & mut self ) -> Option < u8 > {
727735 self . vec . remove ( 0 )
728736 }
@@ -782,6 +790,7 @@ impl String {
782790 ///
783791 /// If `idx` does not lie on a character boundary or is out of bounds, then
784792 /// this function will fail.
793+ #[ unstable = "the failure semantics of this function are uncertain" ]
785794 pub fn insert ( & mut self , idx : uint , ch : char ) {
786795 let len = self . len ( ) ;
787796 assert ! ( idx <= len) ;
@@ -854,7 +863,7 @@ impl FromIterator<char> for String {
854863impl Extendable < char > for String {
855864 fn extend < I : Iterator < char > > ( & mut self , mut iterator : I ) {
856865 for ch in iterator {
857- self . push_char ( ch)
866+ self . push ( ch)
858867 }
859868 }
860869}
@@ -1171,13 +1180,13 @@ mod tests {
11711180 }
11721181
11731182 #[ test]
1174- fn test_push_char ( ) {
1183+ fn test_push ( ) {
11751184 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
11811190 assert_eq ! ( data. as_slice( ) , "ประเทศไทย中华b¢€𤭢" ) ;
11821191 }
11831192
0 commit comments