@@ -423,24 +423,13 @@ impl<T> Vec<T> {
423
423
}
424
424
}
425
425
426
- /// Returns a mutable slice of the elements of `self`.
427
- ///
428
- /// # Examples
429
- ///
430
- /// ```
431
- /// fn foo(slice: &mut [i32]) {}
432
- ///
433
- /// let mut vec = vec![1, 2];
434
- /// foo(vec.as_mut_slice());
435
- /// ```
426
+ /// Deprecated: use `&mut s[..]` instead.
436
427
#[ inline]
437
- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
428
+ #[ unstable( feature = "collections" ,
429
+ reason = "will be replaced by slice syntax" ) ]
430
+ #[ deprecated( since = "1.0.0" , reason = "use &mut s[..] instead" ) ]
438
431
pub fn as_mut_slice ( & mut self ) -> & mut [ T ] {
439
- unsafe {
440
- let ptr = * self . ptr ;
441
- assume ( !ptr. is_null ( ) ) ;
442
- slice:: from_raw_parts_mut ( ptr, self . len )
443
- }
432
+ & mut self [ ..]
444
433
}
445
434
446
435
/// Creates a consuming iterator, that is, one that moves each value out of
@@ -1494,13 +1483,13 @@ impl<T> ops::IndexMut<ops::RangeFull> for Vec<T> {
1494
1483
#[ cfg( stage0) ]
1495
1484
#[ inline]
1496
1485
fn index_mut ( & mut self , _index : & ops:: RangeFull ) -> & mut [ T ] {
1497
- self . as_mut_slice ( )
1486
+ self
1498
1487
}
1499
1488
1500
1489
#[ cfg( not( stage0) ) ]
1501
1490
#[ inline]
1502
1491
fn index_mut ( & mut self , _index : ops:: RangeFull ) -> & mut [ T ] {
1503
- self . as_mut_slice ( )
1492
+ self
1504
1493
}
1505
1494
}
1506
1495
@@ -1519,7 +1508,13 @@ impl<T> ops::Deref for Vec<T> {
1519
1508
1520
1509
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1521
1510
impl < T > ops:: DerefMut for Vec < T > {
1522
- fn deref_mut ( & mut self ) -> & mut [ T ] { self . as_mut_slice ( ) }
1511
+ fn deref_mut ( & mut self ) -> & mut [ T ] {
1512
+ unsafe {
1513
+ let ptr = * self . ptr ;
1514
+ assume ( !ptr. is_null ( ) ) ;
1515
+ slice:: from_raw_parts_mut ( ptr, self . len )
1516
+ }
1517
+ }
1523
1518
}
1524
1519
1525
1520
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -1656,21 +1651,13 @@ impl<T: Ord> Ord for Vec<T> {
1656
1651
}
1657
1652
}
1658
1653
1654
+ #[ unstable( feature = "collections" ,
1655
+ reason = "will be replaced by slice syntax" ) ]
1656
+ #[ deprecated( since = "1.0.0" , reason = "use &mut s[..] instead" ) ]
1659
1657
#[ allow( deprecated) ]
1660
1658
impl < T > AsSlice < T > for Vec < T > {
1661
- /// Returns a slice into `self`.
1662
- ///
1663
- /// # Examples
1664
- ///
1665
- /// ```
1666
- /// # #![feature(core)]
1667
- /// fn foo(slice: &[i32]) {}
1668
- ///
1669
- /// let vec = vec![1, 2];
1670
- /// foo(vec.as_slice());
1671
- /// ```
1659
+ /// Deprecated: use `&mut s[..]` instead.
1672
1660
#[ inline]
1673
- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
1674
1661
fn as_slice ( & self ) -> & [ T ] {
1675
1662
self
1676
1663
}
0 commit comments