Skip to content

Commit 8f6f01d

Browse files
committed
---
yaml --- r: 151454 b: refs/heads/try2 c: 21dae8e h: refs/heads/master v: v3
1 parent 429bf36 commit 8f6f01d

File tree

5 files changed

+58
-58
lines changed

5 files changed

+58
-58
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 4af84313d67e3062e43c0123093278b1887cac64
8+
refs/heads/try2: 21dae8e1e0916afd2f789a2f1affdfe580d9ca0e
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libstd/num/int_macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl ToStrRadix for $T {
8383
});
8484
// We know we generated valid utf-8, so we don't need to go through that
8585
// check.
86-
unsafe { str::raw::from_utf8_owned(buf.move_iter().collect()) }
86+
unsafe { str::raw::from_utf8(buf.as_slice()).to_owned() }
8787
}
8888
}
8989

branches/try2/src/libstd/num/uint_macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl ToStrRadix for $T {
8484
});
8585
// We know we generated valid utf-8, so we don't need to go through that
8686
// check.
87-
unsafe { str::raw::from_utf8_owned(buf.move_iter().collect()) }
87+
unsafe { str::raw::from_utf8(buf.as_slice()).to_owned() }
8888
}
8989
}
9090

branches/try2/src/libstd/slice.rs

Lines changed: 17 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -127,31 +127,31 @@ pub trait VectorVector<T> {
127127
// FIXME #5898: calling these .concat and .connect conflicts with
128128
// StrVector::con{cat,nect}, since they have generic contents.
129129
/// Flattens a vector of vectors of T into a single vector of T.
130-
fn concat_vec(&self) -> ~[T];
130+
fn concat_vec(&self) -> Vec<T>;
131131

132132
/// Concatenate a vector of vectors, placing a given separator between each.
133-
fn connect_vec(&self, sep: &T) -> ~[T];
133+
fn connect_vec(&self, sep: &T) -> Vec<T>;
134134
}
135135

136136
impl<'a, T: Clone, V: Vector<T>> VectorVector<T> for &'a [V] {
137-
fn concat_vec(&self) -> ~[T] {
137+
fn concat_vec(&self) -> Vec<T> {
138138
let size = self.iter().fold(0u, |acc, v| acc + v.as_slice().len());
139139
let mut result = Vec::with_capacity(size);
140140
for v in self.iter() {
141141
result.push_all(v.as_slice())
142142
}
143-
result.move_iter().collect()
143+
result
144144
}
145145

146-
fn connect_vec(&self, sep: &T) -> ~[T] {
146+
fn connect_vec(&self, sep: &T) -> Vec<T> {
147147
let size = self.iter().fold(0u, |acc, v| acc + v.as_slice().len());
148148
let mut result = Vec::with_capacity(size + self.len());
149149
let mut first = true;
150150
for v in self.iter() {
151151
if first { first = false } else { result.push(sep.clone()) }
152152
result.push_all(v.as_slice())
153153
}
154-
result.move_iter().collect()
154+
result
155155
}
156156
}
157157

@@ -185,7 +185,7 @@ pub fn unzip<T, U, V: Iterator<(T, U)>>(mut iter: V) -> (~[T], ~[U]) {
185185
/// The last generated swap is always (0, 1), and it returns the
186186
/// sequence to its initial order.
187187
pub struct ElementSwaps {
188-
sdir: ~[SizeDirection],
188+
sdir: Vec<SizeDirection>,
189189
/// If true, emit the last swap that returns the sequence to initial state
190190
emit_reset: bool,
191191
swaps_made : uint,
@@ -199,9 +199,7 @@ impl ElementSwaps {
199199
// element (equal to the original index).
200200
ElementSwaps{
201201
emit_reset: true,
202-
sdir: range(0, length)
203-
.map(|i| SizeDirection{ size: i, dir: Neg })
204-
.collect::<~[_]>(),
202+
sdir: range(0, length).map(|i| SizeDirection{ size: i, dir: Neg }).collect(),
205203
swaps_made: 0
206204
}
207205
}
@@ -228,12 +226,12 @@ impl Iterator<(uint, uint)> for ElementSwaps {
228226
let max = self.sdir.iter().map(|&x| x).enumerate()
229227
.filter(|&(i, sd)|
230228
new_pos(i, sd.dir) < self.sdir.len() &&
231-
self.sdir[new_pos(i, sd.dir)].size < sd.size)
229+
self.sdir.get(new_pos(i, sd.dir)).size < sd.size)
232230
.max_by(|&(_, sd)| sd.size);
233231
match max {
234232
Some((i, sd)) => {
235233
let j = new_pos(i, sd.dir);
236-
self.sdir.swap(i, j);
234+
self.sdir.as_mut_slice().swap(i, j);
237235

238236
// Swap the direction of each larger SizeDirection
239237
for x in self.sdir.mut_iter() {
@@ -368,7 +366,7 @@ impl<T: Clone> CloneableVector<T> for ~[T] {
368366
pub trait ImmutableCloneableVector<T> {
369367
/// Partitions the vector into two vectors `(A,B)`, where all
370368
/// elements of `A` satisfy `f` and all elements of `B` do not.
371-
fn partitioned(&self, f: |&T| -> bool) -> (~[T], ~[T]);
369+
fn partitioned(&self, f: |&T| -> bool) -> (Vec<T>, Vec<T>);
372370

373371
/// Create an iterator that yields every possible permutation of the
374372
/// vector in succession.
@@ -377,7 +375,7 @@ pub trait ImmutableCloneableVector<T> {
377375

378376
impl<'a,T:Clone> ImmutableCloneableVector<T> for &'a [T] {
379377
#[inline]
380-
fn partitioned(&self, f: |&T| -> bool) -> (~[T], ~[T]) {
378+
fn partitioned(&self, f: |&T| -> bool) -> (Vec<T>, Vec<T>) {
381379
let mut lefts = Vec::new();
382380
let mut rights = Vec::new();
383381

@@ -389,7 +387,7 @@ impl<'a,T:Clone> ImmutableCloneableVector<T> for &'a [T] {
389387
}
390388
}
391389

392-
(lefts.move_iter().collect(), rights.move_iter().collect())
390+
(lefts, rights)
393391
}
394392

395393
fn permutations(self) -> Permutations<T> {
@@ -426,7 +424,7 @@ pub trait OwnedVector<T> {
426424
* Partitions the vector into two vectors `(A,B)`, where all
427425
* elements of `A` satisfy `f` and all elements of `B` do not.
428426
*/
429-
fn partition(self, f: |&T| -> bool) -> (~[T], ~[T]);
427+
fn partition(self, f: |&T| -> bool) -> (Vec<T>, Vec<T>);
430428
}
431429

432430
impl<T> OwnedVector<T> for ~[T] {
@@ -446,7 +444,7 @@ impl<T> OwnedVector<T> for ~[T] {
446444
}
447445

448446
#[inline]
449-
fn partition(self, f: |&T| -> bool) -> (~[T], ~[T]) {
447+
fn partition(self, f: |&T| -> bool) -> (Vec<T>, Vec<T>) {
450448
let mut lefts = Vec::new();
451449
let mut rights = Vec::new();
452450

@@ -458,7 +456,7 @@ impl<T> OwnedVector<T> for ~[T] {
458456
}
459457
}
460458

461-
(lefts.move_iter().collect(), rights.move_iter().collect())
459+
(lefts, rights)
462460
}
463461
}
464462

@@ -1250,6 +1248,7 @@ mod tests {
12501248

12511249
let (left, right) = unzip(z1.iter().map(|&x| x));
12521250

1251+
let (left, right) = (left.as_slice(), right.as_slice());
12531252
assert_eq!((1, 4), (left[0], right[0]));
12541253
assert_eq!((2, 5), (left[1], right[1]));
12551254
assert_eq!((3, 6), (left[2], right[2]));
@@ -1455,43 +1454,6 @@ mod tests {
14551454
}
14561455
}
14571456

1458-
#[test]
1459-
fn test_partition() {
1460-
assert_eq!((box []).partition(|x: &int| *x < 3), (box [], box []));
1461-
assert_eq!((box [1, 2, 3]).partition(|x: &int| *x < 4), (box [1, 2, 3], box []));
1462-
assert_eq!((box [1, 2, 3]).partition(|x: &int| *x < 2), (box [1], box [2, 3]));
1463-
assert_eq!((box [1, 2, 3]).partition(|x: &int| *x < 0), (box [], box [1, 2, 3]));
1464-
}
1465-
1466-
#[test]
1467-
fn test_partitioned() {
1468-
assert_eq!(([]).partitioned(|x: &int| *x < 3), (box [], box []))
1469-
assert_eq!(([1, 2, 3]).partitioned(|x: &int| *x < 4), (box [1, 2, 3], box []));
1470-
assert_eq!(([1, 2, 3]).partitioned(|x: &int| *x < 2), (box [1], box [2, 3]));
1471-
assert_eq!(([1, 2, 3]).partitioned(|x: &int| *x < 0), (box [], box [1, 2, 3]));
1472-
}
1473-
1474-
#[test]
1475-
fn test_concat() {
1476-
let v: [~[int], ..0] = [];
1477-
assert_eq!(v.concat_vec(), box []);
1478-
assert_eq!([box [1], box [2,3]].concat_vec(), box [1, 2, 3]);
1479-
1480-
assert_eq!([&[1], &[2,3]].concat_vec(), box [1, 2, 3]);
1481-
}
1482-
1483-
#[test]
1484-
fn test_connect() {
1485-
let v: [~[int], ..0] = [];
1486-
assert_eq!(v.connect_vec(&0), box []);
1487-
assert_eq!([box [1], box [2, 3]].connect_vec(&0), box [1, 0, 2, 3]);
1488-
assert_eq!([box [1], box [2], box [3]].connect_vec(&0), box [1, 0, 2, 0, 3]);
1489-
1490-
assert_eq!(v.connect_vec(&0), box []);
1491-
assert_eq!([&[1], &[2, 3]].connect_vec(&0), box [1, 0, 2, 3]);
1492-
assert_eq!([&[1], &[2], &[3]].connect_vec(&0), box [1, 0, 2, 0, 3]);
1493-
}
1494-
14951457
#[test]
14961458
fn test_shift() {
14971459
let mut x = vec![1, 2, 3];

branches/try2/src/libstd/vec.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,4 +1649,42 @@ mod tests {
16491649
unsafe { v.set_len(0); }
16501650
assert_eq!(v.mut_iter().len(), 0);
16511651
}
1652+
1653+
#[test]
1654+
fn test_partition() {
1655+
assert_eq!(vec![].partition(|x: &int| *x < 3), (vec![], vec![]));
1656+
assert_eq!(vec![1, 2, 3].partition(|x: &int| *x < 4), (vec![1, 2, 3], vec![]));
1657+
assert_eq!(vec![1, 2, 3].partition(|x: &int| *x < 2), (vec![1], vec![2, 3]));
1658+
assert_eq!(vec![1, 2, 3].partition(|x: &int| *x < 0), (vec![], vec![1, 2, 3]));
1659+
}
1660+
1661+
#[test]
1662+
fn test_partitioned() {
1663+
assert_eq!(([]).partitioned(|x: &int| *x < 3), (vec![], vec![]))
1664+
assert_eq!(([1, 2, 3]).partitioned(|x: &int| *x < 4), (vec![1, 2, 3], vec![]));
1665+
assert_eq!(([1, 2, 3]).partitioned(|x: &int| *x < 2), (vec![1], vec![2, 3]));
1666+
assert_eq!(([1, 2, 3]).partitioned(|x: &int| *x < 0), (vec![], vec![1, 2, 3]));
1667+
}
1668+
1669+
#[test]
1670+
fn test_concat() {
1671+
let v: [Vec<int>, ..0] = [];
1672+
assert_eq!(v.concat_vec(), vec![]);
1673+
assert_eq!([vec![1], vec![2,3]].concat_vec(), vec![1, 2, 3]);
1674+
1675+
assert_eq!([&[1], &[2,3]].concat_vec(), vec![1, 2, 3]);
1676+
}
1677+
1678+
#[test]
1679+
fn test_connect() {
1680+
let v: [~[int], ..0] = [];
1681+
assert_eq!(v.connect_vec(&0), vec![]);
1682+
assert_eq!([vec![1], vec![2, 3]].connect_vec(&0), vec![1, 0, 2, 3]);
1683+
assert_eq!([vec![1], vec![2], vec![3]].connect_vec(&0), vec![1, 0, 2, 0, 3]);
1684+
1685+
let v: [&[int], ..0] = [];
1686+
assert_eq!(v.connect_vec(&0), vec![]);
1687+
assert_eq!([&[1], &[2, 3]].connect_vec(&0), vec![1, 0, 2, 3]);
1688+
assert_eq!([&[1], &[2], &[3]].connect_vec(&0), vec![1, 0, 2, 0, 3]);
1689+
}
16521690
}

0 commit comments

Comments
 (0)