From bc7a2d72a3fea324fa432de9b6ce6073302d3d8c Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Tue, 25 Mar 2014 16:13:11 +1100 Subject: rand: bubble up IO messages futher. The various ...Rng::new() methods can hit IO errors from the OSRng they use, and it seems sensible to expose them at a higher level. Unfortunately, writing e.g. `StdRng::new().unwrap()` gives a much poorer error message than if it failed internally, but this is a problem with all `IoResult`s. --- src/libstd/num/strconv.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/libstd/num') diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs index 9f9a9ec8e2e..c516973ddd5 100644 --- a/src/libstd/num/strconv.rs +++ b/src/libstd/num/strconv.rs @@ -821,31 +821,31 @@ mod bench { #[bench] fn to_str_bin(bh: &mut BenchHarness) { - let mut rng = XorShiftRng::new(); + let mut rng = XorShiftRng::new().unwrap(); bh.iter(|| { rng.gen::().to_str_radix(2); }) } #[bench] fn to_str_oct(bh: &mut BenchHarness) { - let mut rng = XorShiftRng::new(); + let mut rng = XorShiftRng::new().unwrap(); bh.iter(|| { rng.gen::().to_str_radix(8); }) } #[bench] fn to_str_dec(bh: &mut BenchHarness) { - let mut rng = XorShiftRng::new(); + let mut rng = XorShiftRng::new().unwrap(); bh.iter(|| { rng.gen::().to_str_radix(10); }) } #[bench] fn to_str_hex(bh: &mut BenchHarness) { - let mut rng = XorShiftRng::new(); + let mut rng = XorShiftRng::new().unwrap(); bh.iter(|| { rng.gen::().to_str_radix(16); }) } #[bench] fn to_str_base_36(bh: &mut BenchHarness) { - let mut rng = XorShiftRng::new(); + let mut rng = XorShiftRng::new().unwrap(); bh.iter(|| { rng.gen::().to_str_radix(36); }) } } @@ -857,31 +857,31 @@ mod bench { #[bench] fn to_str_bin(bh: &mut BenchHarness) { - let mut rng = XorShiftRng::new(); + let mut rng = XorShiftRng::new().unwrap(); bh.iter(|| { rng.gen::().to_str_radix(2); }) } #[bench] fn to_str_oct(bh: &mut BenchHarness) { - let mut rng = XorShiftRng::new(); + let mut rng = XorShiftRng::new().unwrap(); bh.iter(|| { rng.gen::().to_str_radix(8); }) } #[bench] fn to_str_dec(bh: &mut BenchHarness) { - let mut rng = XorShiftRng::new(); + let mut rng = XorShiftRng::new().unwrap(); bh.iter(|| { rng.gen::().to_str_radix(10); }) } #[bench] fn to_str_hex(bh: &mut BenchHarness) { - let mut rng = XorShiftRng::new(); + let mut rng = XorShiftRng::new().unwrap(); bh.iter(|| { rng.gen::().to_str_radix(16); }) } #[bench] fn to_str_base_36(bh: &mut BenchHarness) { - let mut rng = XorShiftRng::new(); + let mut rng = XorShiftRng::new().unwrap(); bh.iter(|| { rng.gen::().to_str_radix(36); }) } } @@ -893,7 +893,7 @@ mod bench { #[bench] fn float_to_str(bh: &mut BenchHarness) { - let mut rng = XorShiftRng::new(); + let mut rng = XorShiftRng::new().unwrap(); bh.iter(|| { f64::to_str(rng.gen()); }) } } -- cgit 1.4.1-3-g733a5