Skip to content

Commit aaeec84

Browse files
committed
---
yaml --- r: 115166 b: refs/heads/auto c: 803e92d h: refs/heads/master v: v3
1 parent 7bc41ce commit aaeec84

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
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: feb91f3216c7a60c9f7da582b3a02551fe73bb40
16+
refs/heads/auto: 803e92de89def55197244269a5d1feffa00c93d9
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/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

branches/auto/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
}

branches/auto/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());

branches/auto/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)