@@ -438,20 +438,6 @@ pub fn consume_reverse<T>(mut v: ~[T], f: &fn(uint, v: T)) {
438
438
}
439
439
}
440
440
441
- /// Shorten a vector, dropping excess elements.
442
- pub fn truncate < T > ( v : & mut ~[ T ] , newlen : uint ) {
443
- do as_mut_buf ( * v) |p, oldlen| {
444
- assert ! ( newlen <= oldlen) ;
445
- unsafe {
446
- // This loop is optimized out for non-drop types.
447
- for uint:: range( newlen, oldlen) |i| {
448
- ptr:: replace_ptr( ptr:: mut_offset( p, i) , intrinsics:: uninit( ) ) ;
449
- }
450
- }
451
- }
452
- unsafe { raw:: set_len ( & mut * v, newlen) ; }
453
- }
454
-
455
441
/**
456
442
* Remove consecutive repeated elements from a vector; if the vector is
457
443
* sorted, this removes all duplicates.
@@ -1820,9 +1806,18 @@ impl<T> OwnedVector<T> for ~[T] {
1820
1806
self . pop ( )
1821
1807
}
1822
1808
1823
- # [ inline ]
1809
+ /// Shorten a vector, dropping excess elements.
1824
1810
fn truncate ( & mut self , newlen : uint ) {
1825
- truncate ( self , newlen) ;
1811
+ do as_mut_buf ( * self ) |p, oldlen| {
1812
+ assert ! ( newlen <= oldlen) ;
1813
+ unsafe {
1814
+ // This loop is optimized out for non-drop types.
1815
+ for uint:: range( newlen, oldlen) |i| {
1816
+ ptr:: replace_ptr( ptr:: mut_offset( p, i) , intrinsics:: uninit( ) ) ;
1817
+ }
1818
+ }
1819
+ }
1820
+ unsafe { raw:: set_len ( self , newlen) ; }
1826
1821
}
1827
1822
1828
1823
#[ inline]
0 commit comments