@@ -1713,7 +1713,7 @@ pub mod raw {
17131713/// An owned, partially type-converted vector.
17141714///
17151715/// This struct takes two type parameters `T` and `U` which must be of the
1716- /// same, non-zero size.
1716+ /// same, non-zero size having the same minimal alignment .
17171717///
17181718/// No allocations are performed by usage, only a deallocation happens in the
17191719/// destructor which should only run when unwinding.
@@ -1727,12 +1727,12 @@ pub mod raw {
17271727///
17281728/// # Example
17291729///
1730- /// ```rust
1731- /// let pv = PartialVec::from_vec(vec![0u , 1]);
1730+ /// ```ignore
1731+ /// let pv = PartialVec::from_vec(vec![0u32 , 1]);
17321732/// assert_eq!(pv.pop(), Some(0));
17331733/// assert_eq!(pv.pop(), Some(1));
17341734/// assert_eq!(pv.pop(), None);
1735- /// pv.push(2u );
1735+ /// pv.push(2u32 );
17361736/// pv.push(3);
17371737/// assert_eq!(pv.into_vec().as_slice(), &[2, 3]);
17381738/// ```
@@ -1759,7 +1759,7 @@ pub mod raw {
17591759//
17601760// (h) The `min_align_of` of `T` and `U` is equal.
17611761
1762- pub struct PartialVec < T , U > {
1762+ struct PartialVec < T , U > {
17631763 vec : Vec < T > ,
17641764
17651765 start_u : * mut U ,
@@ -1773,8 +1773,9 @@ impl<T,U> PartialVec<T,U> {
17731773 ///
17741774 /// # Failure
17751775 ///
1776- /// Fails if `T` and `U` have differing sizes or are zero-sized.
1777- pub fn from_vec ( mut vec : Vec < T > ) -> PartialVec < T , U > {
1776+ /// Fails if `T` and `U` have differing sizes, are zero-sized or have
1777+ /// differing minimal alignments.
1778+ fn from_vec ( mut vec : Vec < T > ) -> PartialVec < T , U > {
17781779 // FIXME: Assert statically that the types `T` and `U` have the same
17791780 // size.
17801781 //
@@ -1863,7 +1864,7 @@ impl<T,U> PartialVec<T,U> {
18631864 ///
18641865 /// Fails if not enough `T`s were popped to have enough space for the new
18651866 /// `U`.
1866- pub fn push ( & mut self , value : U ) {
1867+ fn push ( & mut self , value : U ) {
18671868 // The assert assures that still `end_u <= start_t` (d) after
18681869 // the function.
18691870 assert ! ( self . end_u as * const ( ) < self . start_t as * const ( ) ,
@@ -1884,7 +1885,7 @@ impl<T,U> PartialVec<T,U> {
18841885 ///
18851886 /// Fails if not all `T`s were popped, also fails if not the same amount of
18861887 /// `U`s was pushed before calling `unwrap`.
1887- pub fn into_vec ( mut self ) -> Vec < U > {
1888+ fn into_vec ( mut self ) -> Vec < U > {
18881889 // If `self.end_u == self.end_t`, we know from (e) that there are no
18891890 // more `T`s in `vec`, we also know that the whole length of `vec` is
18901891 // now used by `U`s, thus we can just interpret `vec` as a vector of
@@ -1944,27 +1945,28 @@ impl<T,U> Iterator<T> for PartialVec<T,U> {
19441945
19451946impl < T > Vec < T > {
19461947 /// Converts a `Vec<T>` to a `Vec<U>` where `T` and `U` have the same
1947- /// non-zero size.
1948+ /// non-zero size and the same minimal alignment .
19481949 ///
19491950 /// # Failure
19501951 ///
1951- /// Fails if `T` and `U` have differing sizes or are zero-sized.
1952+ /// Fails if `T` and `U` have differing sizes, are zero-sized or have
1953+ /// differing minimal alignments.
19521954 ///
19531955 /// # Example
19541956 ///
1955- /// ```rust
1957+ /// ```
19561958 /// let v = vec![0u, 1, 2];
1957- /// let w = v.map_inplace (|i| i + 3);
1959+ /// let w = v.map_in_place (|i| i + 3);
19581960 /// assert_eq!(w.as_slice(), &[3, 4, 5]);
19591961 ///
19601962 /// let big_endian_u16s = vec![0x1122u16, 0x3344];
1961- /// let u8s = big_endian_u16s.map_inplace (|x| [
1963+ /// let u8s = big_endian_u16s.map_in_place (|x| [
19621964 /// ((x >> 8) & 0xff) as u8,
19631965 /// (x & 0xff) as u8
19641966 /// ]);
19651967 /// assert_eq!(u8s.as_slice(), &[[0x11, 0x22], [0x33, 0x44]]);
19661968 /// ```
1967- pub fn map_inplace < U > ( self , f: |T | -> U ) -> Vec < U > {
1969+ pub fn map_in_place < U > ( self , f: |T | -> U ) -> Vec < U > {
19681970 let mut pv = PartialVec :: from_vec ( self ) ;
19691971 loop {
19701972 let maybe_t = pv. pop ( ) ;
@@ -2309,15 +2311,15 @@ mod tests {
23092311
23102312 #[ test]
23112313 #[ should_fail]
2312- fn test_map_inplace_incompatible_types_fail ( ) {
2314+ fn test_map_inp_lace_incompatible_types_fail ( ) {
23132315 let v = vec ! [ 0 u, 1 , 2 ] ;
2314- v. map_inplace ( |_| ( ) ) ;
2316+ v. map_in_place ( |_| ( ) ) ;
23152317 }
23162318
23172319 #[ test]
2318- fn test_map_inplace ( ) {
2320+ fn test_map_in_place ( ) {
23192321 let v = vec ! [ 0 u, 1 , 2 ] ;
2320- assert_eq ! ( v. map_inplace ( |i: uint| i as int - 1 ) . as_slice( ) , & [ -1 i, 0 , 1 ] ) ;
2322+ assert_eq ! ( v. map_in_place ( |i: uint| i as int - 1 ) . as_slice( ) , & [ -1 i, 0 , 1 ] ) ;
23212323 }
23222324
23232325 #[ bench]
0 commit comments