Skip to content

Commit 53135c6

Browse files
committed
---
yaml --- r: 113077 b: refs/heads/try c: 6099f9a h: refs/heads/master i: 113075: 401cef4 v: v3
1 parent e027782 commit 53135c6

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
@@ -2,7 +2,7 @@
22
refs/heads/master: abdacecdf86b4b5a4f432560445a24e1c5f4751b
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 922c420fcd4dfbfc7e3bce4dd20d9b17a20b39f3
5-
refs/heads/try: 5803b1088aefe1e6a8998c4356af2105773e243f
5+
refs/heads/try: 6099f9a0d8157513061eef47b0a54902ab34e72a
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ impl ToStrRadix for $T {
302302
});
303303
// We know we generated valid utf-8, so we don't need to go through that
304304
// check.
305-
unsafe { str::raw::from_utf8_owned(buf.move_iter().collect()) }
305+
unsafe { str::raw::from_utf8(buf.as_slice()).to_owned() }
306306
}
307307
}
308308

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ impl ToStrRadix for $T {
217217
});
218218
// We know we generated valid utf-8, so we don't need to go through that
219219
// check.
220-
unsafe { str::raw::from_utf8_owned(buf.move_iter().collect()) }
220+
unsafe { str::raw::from_utf8(buf.as_slice()).to_owned() }
221221
}
222222
}
223223

branches/try/src/libstd/slice.rs

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

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

246246
impl<'a, T: Clone, V: Vector<T>> VectorVector<T> for &'a [V] {
247-
fn concat_vec(&self) -> ~[T] {
247+
fn concat_vec(&self) -> Vec<T> {
248248
let size = self.iter().fold(0u, |acc, v| acc + v.as_slice().len());
249249
let mut result = Vec::with_capacity(size);
250250
for v in self.iter() {
251251
result.push_all(v.as_slice())
252252
}
253-
result.move_iter().collect()
253+
result
254254
}
255255

256-
fn connect_vec(&self, sep: &T) -> ~[T] {
256+
fn connect_vec(&self, sep: &T) -> Vec<T> {
257257
let size = self.iter().fold(0u, |acc, v| acc + v.as_slice().len());
258258
let mut result = Vec::with_capacity(size + self.len());
259259
let mut first = true;
260260
for v in self.iter() {
261261
if first { first = false } else { result.push(sep.clone()) }
262262
result.push_all(v.as_slice())
263263
}
264-
result.move_iter().collect()
264+
result
265265
}
266266
}
267267

@@ -295,7 +295,7 @@ pub fn unzip<T, U, V: Iterator<(T, U)>>(mut iter: V) -> (~[T], ~[U]) {
295295
/// The last generated swap is always (0, 1), and it returns the
296296
/// sequence to its initial order.
297297
pub struct ElementSwaps {
298-
sdir: ~[SizeDirection],
298+
sdir: Vec<SizeDirection>,
299299
/// If true, emit the last swap that returns the sequence to initial state
300300
emit_reset: bool,
301301
swaps_made : uint,
@@ -309,9 +309,7 @@ impl ElementSwaps {
309309
// element (equal to the original index).
310310
ElementSwaps{
311311
emit_reset: true,
312-
sdir: range(0, length)
313-
.map(|i| SizeDirection{ size: i, dir: Neg })
314-
.collect::<~[_]>(),
312+
sdir: range(0, length).map(|i| SizeDirection{ size: i, dir: Neg }).collect(),
315313
swaps_made: 0
316314
}
317315
}
@@ -338,12 +336,12 @@ impl Iterator<(uint, uint)> for ElementSwaps {
338336
let max = self.sdir.iter().map(|&x| x).enumerate()
339337
.filter(|&(i, sd)|
340338
new_pos(i, sd.dir) < self.sdir.len() &&
341-
self.sdir[new_pos(i, sd.dir)].size < sd.size)
339+
self.sdir.get(new_pos(i, sd.dir)).size < sd.size)
342340
.max_by(|&(_, sd)| sd.size);
343341
match max {
344342
Some((i, sd)) => {
345343
let j = new_pos(i, sd.dir);
346-
self.sdir.swap(i, j);
344+
self.sdir.as_mut_slice().swap(i, j);
347345

348346
// Swap the direction of each larger SizeDirection
349347
for x in self.sdir.mut_iter() {
@@ -1132,7 +1130,7 @@ impl<'a, T: TotalOrd> ImmutableTotalOrdVector<T> for &'a [T] {
11321130
pub trait ImmutableCloneableVector<T> {
11331131
/// Partitions the vector into two vectors `(A,B)`, where all
11341132
/// elements of `A` satisfy `f` and all elements of `B` do not.
1135-
fn partitioned(&self, f: |&T| -> bool) -> (~[T], ~[T]);
1133+
fn partitioned(&self, f: |&T| -> bool) -> (Vec<T>, Vec<T>);
11361134

11371135
/// Create an iterator that yields every possible permutation of the
11381136
/// vector in succession.
@@ -1141,7 +1139,7 @@ pub trait ImmutableCloneableVector<T> {
11411139

11421140
impl<'a,T:Clone> ImmutableCloneableVector<T> for &'a [T] {
11431141
#[inline]
1144-
fn partitioned(&self, f: |&T| -> bool) -> (~[T], ~[T]) {
1142+
fn partitioned(&self, f: |&T| -> bool) -> (Vec<T>, Vec<T>) {
11451143
let mut lefts = Vec::new();
11461144
let mut rights = Vec::new();
11471145

@@ -1153,7 +1151,7 @@ impl<'a,T:Clone> ImmutableCloneableVector<T> for &'a [T] {
11531151
}
11541152
}
11551153

1156-
(lefts.move_iter().collect(), rights.move_iter().collect())
1154+
(lefts, rights)
11571155
}
11581156

11591157
fn permutations(self) -> Permutations<T> {
@@ -1190,7 +1188,7 @@ pub trait OwnedVector<T> {
11901188
* Partitions the vector into two vectors `(A,B)`, where all
11911189
* elements of `A` satisfy `f` and all elements of `B` do not.
11921190
*/
1193-
fn partition(self, f: |&T| -> bool) -> (~[T], ~[T]);
1191+
fn partition(self, f: |&T| -> bool) -> (Vec<T>, Vec<T>);
11941192
}
11951193

11961194
impl<T> OwnedVector<T> for ~[T] {
@@ -1210,7 +1208,7 @@ impl<T> OwnedVector<T> for ~[T] {
12101208
}
12111209

12121210
#[inline]
1213-
fn partition(self, f: |&T| -> bool) -> (~[T], ~[T]) {
1211+
fn partition(self, f: |&T| -> bool) -> (Vec<T>, Vec<T>) {
12141212
let mut lefts = Vec::new();
12151213
let mut rights = Vec::new();
12161214

@@ -1222,7 +1220,7 @@ impl<T> OwnedVector<T> for ~[T] {
12221220
}
12231221
}
12241222

1225-
(lefts.move_iter().collect(), rights.move_iter().collect())
1223+
(lefts, rights)
12261224
}
12271225
}
12281226

@@ -2745,6 +2743,7 @@ mod tests {
27452743

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

2746+
let (left, right) = (left.as_slice(), right.as_slice());
27482747
assert_eq!((1, 4), (left[0], right[0]));
27492748
assert_eq!((2, 5), (left[1], right[1]));
27502749
assert_eq!((3, 6), (left[2], right[2]));
@@ -2950,43 +2949,6 @@ mod tests {
29502949
}
29512950
}
29522951

2953-
#[test]
2954-
fn test_partition() {
2955-
assert_eq!((box []).partition(|x: &int| *x < 3), (box [], box []));
2956-
assert_eq!((box [1, 2, 3]).partition(|x: &int| *x < 4), (box [1, 2, 3], box []));
2957-
assert_eq!((box [1, 2, 3]).partition(|x: &int| *x < 2), (box [1], box [2, 3]));
2958-
assert_eq!((box [1, 2, 3]).partition(|x: &int| *x < 0), (box [], box [1, 2, 3]));
2959-
}
2960-
2961-
#[test]
2962-
fn test_partitioned() {
2963-
assert_eq!(([]).partitioned(|x: &int| *x < 3), (box [], box []))
2964-
assert_eq!(([1, 2, 3]).partitioned(|x: &int| *x < 4), (box [1, 2, 3], box []));
2965-
assert_eq!(([1, 2, 3]).partitioned(|x: &int| *x < 2), (box [1], box [2, 3]));
2966-
assert_eq!(([1, 2, 3]).partitioned(|x: &int| *x < 0), (box [], box [1, 2, 3]));
2967-
}
2968-
2969-
#[test]
2970-
fn test_concat() {
2971-
let v: [~[int], ..0] = [];
2972-
assert_eq!(v.concat_vec(), box []);
2973-
assert_eq!([box [1], box [2,3]].concat_vec(), box [1, 2, 3]);
2974-
2975-
assert_eq!([&[1], &[2,3]].concat_vec(), box [1, 2, 3]);
2976-
}
2977-
2978-
#[test]
2979-
fn test_connect() {
2980-
let v: [~[int], ..0] = [];
2981-
assert_eq!(v.connect_vec(&0), box []);
2982-
assert_eq!([box [1], box [2, 3]].connect_vec(&0), box [1, 0, 2, 3]);
2983-
assert_eq!([box [1], box [2], box [3]].connect_vec(&0), box [1, 0, 2, 0, 3]);
2984-
2985-
assert_eq!(v.connect_vec(&0), box []);
2986-
assert_eq!([&[1], &[2, 3]].connect_vec(&0), box [1, 0, 2, 3]);
2987-
assert_eq!([&[1], &[2], &[3]].connect_vec(&0), box [1, 0, 2, 0, 3]);
2988-
}
2989-
29902952
#[test]
29912953
fn test_shift() {
29922954
let mut x = vec![1, 2, 3];

branches/try/src/libstd/vec.rs

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

0 commit comments

Comments
 (0)