@@ -1710,9 +1710,6 @@ pub mod raw {
1710
1710
}
1711
1711
}
1712
1712
1713
- // TODO: Find some way to statically assert that `T` and `U` have the same
1714
- // size.
1715
- //
1716
1713
/// An owned, partially type-converted vector.
1717
1714
///
1718
1715
/// No allocations are performed by usage, only a deallocation happens in the
@@ -1734,7 +1731,7 @@ pub mod raw {
1734
1731
/// assert_eq!(pv.pop(), None);
1735
1732
/// pv.push(2u);
1736
1733
/// pv.push(3);
1737
- /// assert_eq!(pv.unwrap (), vec![2, 3]);
1734
+ /// assert_eq!(pv.into_vec (), vec![2, 3]);
1738
1735
/// ```
1739
1736
//
1740
1737
// Upheld invariants:
@@ -1767,7 +1764,7 @@ pub struct PartialVec<T,U> {
1767
1764
impl < T , U > PartialVec < T , U > {
1768
1765
/// Creates a `PartialVec` from a `Vec`.
1769
1766
pub fn new ( mut vec : Vec < T > ) -> PartialVec < T , U > {
1770
- // TODO: do this statically
1767
+ // FIXME: Assert that the types `T` and `U` have the same size.
1771
1768
assert ! ( mem:: size_of:: <T >( ) != 0 ) ;
1772
1769
assert ! ( mem:: size_of:: <U >( ) != 0 ) ;
1773
1770
assert ! ( mem:: size_of:: <T >( ) == mem:: size_of:: <U >( ) ) ;
@@ -1872,7 +1869,7 @@ impl<T,U> PartialVec<T,U> {
1872
1869
///
1873
1870
/// Fails if not all `T`s were popped, also fails if not the same amount of
1874
1871
/// `U`s was pushed before calling `unwrap`.
1875
- pub fn unwrap ( self ) -> Vec < U > {
1872
+ pub fn into_vec ( self ) -> Vec < U > {
1876
1873
// If `self.end_u == self.end_t`, we know from (e) that there are no
1877
1874
// more `T`s in `vec`, we also know that the whole length of `vec` is
1878
1875
// now used by `U`s, thus we can just transmute `vec` from a vector of
@@ -1945,11 +1942,10 @@ impl<T> Vec<T> {
1945
1942
pub fn map_inplace < U > ( self , f: |T | -> U ) -> Vec < U > {
1946
1943
let mut pv = PartialVec :: new ( self ) ;
1947
1944
loop {
1948
- // TODO: need this extra assignment for borrowck to pass
1949
1945
let maybe_t = pv. pop ( ) ;
1950
1946
match maybe_t {
1951
1947
Some ( t) => pv. push ( f ( t) ) ,
1952
- None => return pv. unwrap ( ) ,
1948
+ None => return pv. into_vec ( ) ,
1953
1949
} ;
1954
1950
}
1955
1951
}
0 commit comments