Skip to content

Commit cb8536f

Browse files
committed
---
yaml --- r: 23551 b: refs/heads/master c: 206edf6 h: refs/heads/master i: 23549: bc7b3bd 23547: 4cf2c74 23543: c4e44f2 23535: 23898a8 23519: 3f18130 23487: 54eec5c 23423: b499a73 23295: b20c4a3 23039: 9194f5b 22527: 8f84e2e v: v3
1 parent 2c8651c commit cb8536f

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
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 0a01d82f6f3e33ca742c8e985d2a4819faeafe40
2+
refs/heads/master: 206edf66c92e12f1d98b56ea48a340e7e86d8552
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/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]

trunk/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)