Skip to content

Commit ee3913d

Browse files
committed
---
yaml --- r: 133709 b: refs/heads/try c: af29337 h: refs/heads/master i: 133707: a4a6fb9 v: v3
1 parent e689749 commit ee3913d

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 0e784e16840e8a0c623cc6166de26da9334db3d6
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 828e075abd8ee2f8c16f6cb1b93c0d99307e704d
5-
refs/heads/try: dbc3cb3a54c02211d8e4f9ff082c4ee2d544ec7d
5+
refs/heads/try: af293372e4ea9578840338bdd1b765bfc3c80352
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libcollections/vec.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,9 +1710,6 @@ pub mod raw {
17101710
}
17111711
}
17121712

1713-
// TODO: Find some way to statically assert that `T` and `U` have the same
1714-
// size.
1715-
//
17161713
/// An owned, partially type-converted vector.
17171714
///
17181715
/// No allocations are performed by usage, only a deallocation happens in the
@@ -1734,7 +1731,7 @@ pub mod raw {
17341731
/// assert_eq!(pv.pop(), None);
17351732
/// pv.push(2u);
17361733
/// pv.push(3);
1737-
/// assert_eq!(pv.unwrap(), vec![2, 3]);
1734+
/// assert_eq!(pv.into_vec(), vec![2, 3]);
17381735
/// ```
17391736
//
17401737
// Upheld invariants:
@@ -1767,7 +1764,7 @@ pub struct PartialVec<T,U> {
17671764
impl<T,U> PartialVec<T,U> {
17681765
/// Creates a `PartialVec` from a `Vec`.
17691766
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.
17711768
assert!(mem::size_of::<T>() != 0);
17721769
assert!(mem::size_of::<U>() != 0);
17731770
assert!(mem::size_of::<T>() == mem::size_of::<U>());
@@ -1872,7 +1869,7 @@ impl<T,U> PartialVec<T,U> {
18721869
///
18731870
/// Fails if not all `T`s were popped, also fails if not the same amount of
18741871
/// `U`s was pushed before calling `unwrap`.
1875-
pub fn unwrap(self) -> Vec<U> {
1872+
pub fn into_vec(self) -> Vec<U> {
18761873
// If `self.end_u == self.end_t`, we know from (e) that there are no
18771874
// more `T`s in `vec`, we also know that the whole length of `vec` is
18781875
// now used by `U`s, thus we can just transmute `vec` from a vector of
@@ -1945,11 +1942,10 @@ impl<T> Vec<T> {
19451942
pub fn map_inplace<U>(self, f: |T| -> U) -> Vec<U> {
19461943
let mut pv = PartialVec::new(self);
19471944
loop {
1948-
// TODO: need this extra assignment for borrowck to pass
19491945
let maybe_t = pv.pop();
19501946
match maybe_t {
19511947
Some(t) => pv.push(f(t)),
1952-
None => return pv.unwrap(),
1948+
None => return pv.into_vec(),
19531949
};
19541950
}
19551951
}

0 commit comments

Comments
 (0)