@@ -17,6 +17,7 @@ use cast;
17
17
use container:: { Container , Mutable } ;
18
18
use cmp;
19
19
use cmp:: { Eq , TotalEq , TotalOrd , Ordering , Less , Equal , Greater } ;
20
+ use ops:: Index ;
20
21
use clone:: Clone ;
21
22
use iterator:: { FromIterator , Iterator , IteratorUtil } ;
22
23
use kinds:: Copy ;
@@ -1758,47 +1759,47 @@ impl<T> VecRef<T> {
1758
1759
// on self-by-value, which means VecRef would move into
1759
1760
// it. So I'm just gonna re-impl here
1760
1761
1761
- #[ inline]
1762
+ #[ inline] # [ allow ( missing_doc ) ]
1762
1763
pub fn iter < ' r > ( & ' r self ) -> VecIterator < ' r , T > {
1763
1764
self . as_slice ( ) . iter ( )
1764
1765
}
1765
1766
1766
- #[ inline]
1767
+ #[ inline] # [ allow ( missing_doc ) ]
1767
1768
pub fn rev_iter < ' r > ( & ' r self ) -> VecRevIterator < ' r , T > {
1768
1769
self . as_slice ( ) . rev_iter ( )
1769
1770
}
1770
1771
1771
- #[ inline]
1772
+ #[ inline] # [ allow ( missing_doc ) ]
1772
1773
pub fn split_iter < ' r > ( & ' r self , pred : & ' r fn ( & T ) -> bool ) -> VecSplitIterator < ' r , T > {
1773
1774
self . as_slice ( ) . split_iter ( pred)
1774
1775
}
1775
1776
1776
- #[ inline]
1777
+ #[ inline] # [ allow ( missing_doc ) ]
1777
1778
pub fn splitn_iter < ' r > ( & ' r self , n : uint , pred : & ' r fn ( & T ) -> bool ) -> VecSplitIterator < ' r , T > {
1778
- self . as_slice ( ) . split_iter ( n, pred)
1779
+ self . as_slice ( ) . splitn_iter ( n, pred)
1779
1780
}
1780
1781
1781
- #[ inline]
1782
+ #[ inline] # [ allow ( missing_doc ) ]
1782
1783
pub fn rsplit_iter < ' r > ( & ' r self , pred : & ' r fn ( & T ) -> bool ) -> VecRSplitIterator < ' r , T > {
1783
1784
self . as_slice ( ) . rsplit_iter ( pred)
1784
1785
}
1785
1786
1786
- #[ inline]
1787
- pub fn rsplitn_iter < ' r > ( & ' r self , pred : & ' r fn ( & T ) -> bool ) -> VecRSplitIterator < ' r , T > {
1788
- self . as_slice ( ) . rsplit_iter ( pred)
1787
+ #[ inline] # [ allow ( missing_doc ) ]
1788
+ pub fn rsplitn_iter < ' r > ( & ' r self , n : uint , pred : & ' r fn ( & T ) -> bool ) -> VecRSplitIterator < ' r , T > {
1789
+ self . as_slice ( ) . rsplitn_iter ( n , pred)
1789
1790
}
1790
1791
1791
- #[ inline]
1792
+ #[ inline] # [ allow ( missing_doc ) ]
1792
1793
pub fn window_iter < ' r > ( & ' r self , size : uint ) -> VecWindowIter < ' r , T > {
1793
1794
self . as_slice ( ) . window_iter ( size)
1794
1795
}
1795
1796
1796
- #[ inline]
1797
+ #[ inline] # [ allow ( missing_doc ) ]
1797
1798
pub fn chunk_iter < ' r > ( & ' r self , size : uint ) -> VecChunkIter < ' r , T > {
1798
- self . as_slice ( ) . window_iter ( size)
1799
+ self . as_slice ( ) . chunk_iter ( size)
1799
1800
}
1800
1801
1801
- #[ inline]
1802
+ #[ inline] # [ allow ( missing_doc ) ]
1802
1803
pub fn as_imm_buf < U > ( & self , f : & fn ( * T , uint ) -> U ) -> U {
1803
1804
self . as_slice ( ) . as_imm_buf ( f)
1804
1805
}
@@ -1809,7 +1810,7 @@ impl<T:Copy> VecRef<T> {
1809
1810
/**
1810
1811
* Converts this type into a standard owned vector, consuming it in the process.
1811
1812
*
1812
- * If the VecRef holds a static vector, it is converted to an owned one, otherwise the held
1813
+ * If the VecRef holds a static vector, it is copied to an owned one, otherwise the held
1813
1814
* owned vector is returned.
1814
1815
*/
1815
1816
pub fn to_owned_consume ( self ) -> ~[ T ] {
@@ -1858,7 +1859,7 @@ impl<T:Eq> ImmutableEqVector<T> for VecRef<T> {
1858
1859
1859
1860
#[ inline]
1860
1861
fn rposition_elem ( & self , t : & T ) -> Option < uint > {
1861
- self . as_slice ( ) . rposition ( t)
1862
+ self . as_slice ( ) . rposition_elem ( t)
1862
1863
}
1863
1864
1864
1865
#[ inline]
@@ -1887,8 +1888,8 @@ impl<T:Copy> ImmutableCopyableVector<T> for VecRef<T> {
1887
1888
}
1888
1889
1889
1890
impl < T : Copy > Index < uint , T > for VecRef < T > {
1890
- fn index ( & self , index : uint ) -> T {
1891
- copy self . as_slice ( ) [ index]
1891
+ fn index ( & self , index : & uint ) -> T {
1892
+ copy self . as_slice ( ) [ * index]
1892
1893
}
1893
1894
}
1894
1895
@@ -3443,10 +3444,10 @@ mod tests {
3443
3444
let v = VecRef :: from_owned( ~[ 1 , 2 , 3 ] ) ;
3444
3445
assert_eq ! ( v. len( ) , 3 ) ;
3445
3446
3446
- let v : VecRef < int > = VecRef :: from_static( [ ] ) ;
3447
+ let v : VecRef < int > = VecRef :: from_static( & [ ] ) ;
3447
3448
assert ! ( v. is_empty( ) ) ;
3448
3449
3449
- let v : VecRef < int > = VecRef :: from_static( [ 1 , 2 , 3 , 4 ] ) ;
3450
+ let v : VecRef < int > = VecRef :: from_static( & [ 1 , 2 , 3 , 4 ] ) ;
3450
3451
assert_eq ! ( v. len( ) , 4 ) ;
3451
3452
}
3452
3453
@@ -3456,8 +3457,21 @@ mod tests {
3456
3457
let vec = v. to_owned_consume( ) ;
3457
3458
assert_eq!( vec, ~[ 1 , 2 , 3 , 4 ] ) ;
3458
3459
3459
- let v = VecRef :: from_static( [ 1 , 2 , 3 , 4 ] ) ;
3460
+ let v = VecRef :: from_static( & [ 1 , 2 , 3 , 4 ] ) ;
3460
3461
let vec = v. to_owned_consume( ) ;
3461
3462
assert_eq!( vec, ~[ 1 , 2 , 3 , 4 ] ) ;
3462
3463
}
3464
+
3465
+ #[ test]
3466
+ fn test_vec_iter( ) {
3467
+ let v = VecRef :: from_static( & [ 1 , 2 , 3 , 4 ] ) ;
3468
+
3469
+ let mut iter = v. iter( ) . transform( |& x| x) ;
3470
+
3471
+ assert_eq!( iter. next( ) , Some ( 1 ) ) ;
3472
+ assert_eq ! ( iter. next( ) , Some ( 2 ) ) ;
3473
+ assert_eq ! ( iter. next( ) , Some ( 3 ) ) ;
3474
+ assert_eq ! ( iter. next( ) , Some ( 4 ) ) ;
3475
+ assert_eq ! ( iter. next( ) , None ) ;
3476
+ }
3463
3477
}
0 commit comments