Skip to content

Commit d6e09c4

Browse files
committed
---
yaml --- r: 114349 b: refs/heads/master c: 803e92d h: refs/heads/master i: 114347: 0fe3e41 v: v3
1 parent 8a7f165 commit d6e09c4

File tree

5 files changed

+20
-26
lines changed

5 files changed

+20
-26
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: feb91f3216c7a60c9f7da582b3a02551fe73bb40
2+
refs/heads/master: 803e92de89def55197244269a5d1feffa00c93d9
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ec0258a381b88b5574e3f8ce72ae553ac3a574b7
55
refs/heads/try: 7c6c492fb2af9a85f21ff952942df3523b22fd17

trunk/src/doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ struct Foo { x: int, y: Box<int> }
944944
// `a` is the owner of the struct, and thus the owner of the struct's fields
945945
let a = Foo { x: 5, y: box 10 };
946946
}
947-
// when `a` goes out of scope, the destructor for the `~int` in the struct's
947+
// when `a` goes out of scope, the destructor for the `Box<int>` in the struct's
948948
// field is called
949949
950950
// `b` is mutable, and the mutability is inherited by the objects it owns

trunk/src/libcore/iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2016,7 +2016,7 @@ pub struct RangeInclusive<A> {
20162016

20172017
/// Return an iterator over the range [start, stop]
20182018
#[inline]
2019-
pub fn range_inclusive<A: Add<A, A> + Ord + Clone + One + ToPrimitive>(start: A, stop: A)
2019+
pub fn range_inclusive<A: Add<A, A> + Ord + Clone + One>(start: A, stop: A)
20202020
-> RangeInclusive<A> {
20212021
RangeInclusive{range: range(start, stop), done: false}
20222022
}

trunk/src/libflate/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ mod tests {
125125
for _ in range(0, 20) {
126126
let mut input = vec![];
127127
for _ in range(0, 2000) {
128-
input.push_all(r.choose(words.as_slice()).as_slice());
128+
input.push_all(r.choose(words.as_slice()).unwrap().as_slice());
129129
}
130130
debug!("de/inflate of {} bytes of random word-sequences",
131131
input.len());

trunk/src/librand/lib.rs

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -266,37 +266,39 @@ pub trait Rng {
266266
0123456789");
267267
let mut s = StrBuf::with_capacity(len);
268268
for _ in range(0, len) {
269-
s.push_char(self.choose(GEN_ASCII_STR_CHARSET) as char)
269+
s.push_char(*self.choose(GEN_ASCII_STR_CHARSET).unwrap() as char)
270270
}
271271
s
272272
}
273273

274-
/// Choose an item randomly, failing if `values` is empty.
275-
fn choose<T: Clone>(&mut self, values: &[T]) -> T {
276-
self.choose_option(values).expect("Rng.choose: `values` is empty").clone()
277-
}
278-
279-
/// Choose `Some(&item)` randomly, returning `None` if values is
280-
/// empty.
274+
/// Return a random element from `values`.
275+
///
276+
/// Return `None` if `values` is empty.
281277
///
282278
/// # Example
283279
///
284-
/// ```rust
280+
/// ```
285281
/// use rand::{task_rng, Rng};
286282
///
287283
/// let choices = [1, 2, 4, 8, 16, 32];
288284
/// let mut rng = task_rng();
289-
/// println!("{:?}", rng.choose_option(choices));
290-
/// println!("{:?}", rng.choose_option(choices.slice_to(0)));
285+
/// println!("{}", rng.choose(choices));
286+
/// assert_eq!(rng.choose(choices.slice_to(0)), None);
291287
/// ```
292-
fn choose_option<'a, T>(&mut self, values: &'a [T]) -> Option<&'a T> {
288+
fn choose<'a, T>(&mut self, values: &'a [T]) -> Option<&'a T> {
293289
if values.is_empty() {
294290
None
295291
} else {
296292
Some(&values[self.gen_range(0u, values.len())])
297293
}
298294
}
299295

296+
/// Deprecated name for `choose()`.
297+
#[deprecated = "replaced by .choose()"]
298+
fn choose_option<'a, T>(&mut self, values: &'a [T]) -> Option<&'a T> {
299+
self.choose(values)
300+
}
301+
300302
/// Shuffle a mutable slice in place.
301303
///
302304
/// # Example
@@ -793,18 +795,10 @@ mod test {
793795
#[test]
794796
fn test_choose() {
795797
let mut r = task_rng();
796-
assert_eq!(r.choose([1, 1, 1]), 1);
797-
}
798+
assert_eq!(r.choose([1, 1, 1]).map(|&x|x), Some(1));
798799

799-
#[test]
800-
fn test_choose_option() {
801-
let mut r = task_rng();
802800
let v: &[int] = &[];
803-
assert!(r.choose_option(v).is_none());
804-
805-
let i = 1;
806-
let v = [1,1,1];
807-
assert_eq!(r.choose_option(v), Some(&i));
801+
assert_eq!(r.choose(v), None);
808802
}
809803

810804
#[test]

0 commit comments

Comments
 (0)