Skip to content

Commit 8032633

Browse files
committed
---
yaml --- r: 30151 b: refs/heads/incoming c: 206edf6 h: refs/heads/master i: 30149: 22c428f 30147: db59ef2 30143: 8a8d67c v: v3
1 parent 5f84184 commit 8032633

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
9-
refs/heads/incoming: 0a01d82f6f3e33ca742c8e985d2a4819faeafe40
9+
refs/heads/incoming: 206edf66c92e12f1d98b56ea48a340e7e86d8552
1010
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/libcore/rand.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,12 @@ impl Rng {
165165
}
166166

167167
/// Choose an item randomly, failing if values is empty
168-
fn choose<T:copy>(values: ~[T]) -> T {
168+
fn choose<T:copy>(values: &[T]) -> T {
169169
self.choose_option(values).get()
170170
}
171171

172172
/// Choose Some(item) randomly, returning None if values is empty
173-
fn choose_option<T:copy>(values: ~[T]) -> Option<T> {
173+
fn choose_option<T:copy>(values: &[T]) -> Option<T> {
174174
if values.is_empty() {
175175
None
176176
} else {
@@ -182,15 +182,15 @@ impl Rng {
182182
* Choose an item respecting the relative weights, failing if the sum of
183183
* the weights is 0
184184
*/
185-
fn choose_weighted<T: copy>(v : ~[Weighted<T>]) -> T {
185+
fn choose_weighted<T: copy>(v : &[Weighted<T>]) -> T {
186186
self.choose_weighted_option(v).get()
187187
}
188188

189189
/**
190190
* Choose Some(item) respecting the relative weights, returning none if
191191
* the sum of the weights is 0
192192
*/
193-
fn choose_weighted_option<T:copy>(v: ~[Weighted<T>]) -> Option<T> {
193+
fn choose_weighted_option<T:copy>(v: &[Weighted<T>]) -> Option<T> {
194194
let mut total = 0u;
195195
for v.each |item| {
196196
total += item.weight;
@@ -213,7 +213,7 @@ impl Rng {
213213
* Return a vec containing copies of the items, in order, where
214214
* the weight of the item determines how many copies there are
215215
*/
216-
fn weighted_vec<T:copy>(v: ~[Weighted<T>]) -> ~[T] {
216+
fn weighted_vec<T:copy>(v: &[Weighted<T>]) -> ~[T] {
217217
let mut r = ~[];
218218
for v.each |item| {
219219
for uint::range(0u, item.weight) |_i| {
@@ -224,14 +224,14 @@ impl Rng {
224224
}
225225

226226
/// Shuffle a vec
227-
fn shuffle<T:copy>(values: ~[T]) -> ~[T] {
228-
let mut m = vec::to_mut(values);
227+
fn shuffle<T:copy>(values: &[T]) -> ~[T] {
228+
let mut m = vec::from_slice(values);
229229
self.shuffle_mut(m);
230-
return vec::from_mut(m);
230+
return m;
231231
}
232232

233233
/// Shuffle a mutable vec in place
234-
fn shuffle_mut<T>(&&values: ~[mut T]) {
234+
fn shuffle_mut<T>(values: &[mut T]) {
235235
let mut i = values.len();
236236
while i >= 2u {
237237
// invariant: elements with index >= i have been locked in place.
@@ -402,14 +402,14 @@ mod tests {
402402
#[test]
403403
fn choose() {
404404
let r = rand::Rng();
405-
assert r.choose(~[1, 1, 1]) == 1;
405+
assert r.choose([1, 1, 1]) == 1;
406406
}
407407

408408
#[test]
409409
fn choose_option() {
410410
let r = rand::Rng();
411-
assert r.choose_option(~[]).is_none();
412-
assert r.choose_option(~[1, 1, 1]) == Some(1);
411+
assert r.choose_option::<int>([]).is_none();
412+
assert r.choose_option([1, 1, 1]) == Some(1);
413413
}
414414

415415
#[test]
@@ -431,7 +431,7 @@ mod tests {
431431
{weight: 0u, item: 42},
432432
{weight: 1u, item: 43}
433433
]) == Some(43);
434-
assert r.choose_weighted_option(~[]).is_none();
434+
assert r.choose_weighted_option::<int>([]).is_none();
435435
}
436436

437437
#[test]

branches/incoming/src/libcore/vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ pure fn zip<T, U>(+v: ~[const T], +u: ~[const U]) -> ~[(T, U)] {
10861086
* * a - The index of the first element
10871087
* * b - The index of the second element
10881088
*/
1089-
fn swap<T>(&&v: ~[mut T], a: uint, b: uint) {
1089+
fn swap<T>(v: &[mut T], a: uint, b: uint) {
10901090
v[a] <-> v[b];
10911091
}
10921092

0 commit comments

Comments
 (0)