Skip to content

Commit bc9de77

Browse files
author
Subhash Bhushan
committed
Rename remaining Failures to Panic
1 parent 394269d commit bc9de77

File tree

20 files changed

+57
-41
lines changed

20 files changed

+57
-41
lines changed

src/libcollections/slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ fn merge_sort<T>(v: &mut [T], compare: |&T, &T| -> Ordering) {
424424
// allocate some memory to use as scratch memory, we keep the
425425
// length 0 so we can keep shallow copies of the contents of `v`
426426
// without risking the dtors running on an object twice if
427-
// `compare` fails.
427+
// `compare` panics.
428428
let mut working_space = Vec::with_capacity(2 * len);
429429
// these both are buffers of length `len`.
430430
let mut buf_dat = working_space.as_mut_ptr();

src/libcore/option.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ impl<T> Option<T> {
303303
///
304304
/// # Panics
305305
///
306-
/// Fails if the value is a `None` with a custom panic message provided by
306+
/// Panics if the value is a `None` with a custom panic message provided by
307307
/// `msg`.
308308
///
309309
/// # Example
@@ -315,7 +315,7 @@ impl<T> Option<T> {
315315
///
316316
/// ```{.should_fail}
317317
/// let x: Option<&str> = None;
318-
/// x.expect("the world is ending"); // fails with `world is ending`
318+
/// x.expect("the world is ending"); // panics with `world is ending`
319319
/// ```
320320
#[inline]
321321
#[unstable = "waiting for conventions"]

src/libgetopts/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ impl fmt::Show for Fail_ {
569569
///
570570
/// On success returns `Ok(Matches)`. Use methods such as `opt_present`
571571
/// `opt_str`, etc. to interrogate results.
572-
/// # Errors
572+
/// # Panics
573573
///
574574
/// Returns `Err(Fail_)` on failure: use the `Show` implementation of `Fail_` to display
575575
/// information about it.
@@ -860,9 +860,9 @@ enum LengthLimit {
860860
/// Note: Function was moved here from `std::str` because this module is the only place that
861861
/// uses it, and because it was too specific for a general string function.
862862
///
863-
/// #Failure:
863+
/// # Panics
864864
///
865-
/// Fails during iteration if the string contains a non-whitespace
865+
/// Panics during iteration if the string contains a non-whitespace
866866
/// sequence longer than the limit.
867867
fn each_split_within<'a>(ss: &'a str, lim: uint, it: |&'a str| -> bool)
868868
-> bool {

src/libgreen/stack.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl Stack {
4242
pub fn new(size: uint) -> Stack {
4343
// Map in a stack. Eventually we might be able to handle stack
4444
// allocation failure, which would fail to spawn the task. But there's
45-
// not many sensible things to do on OOM. Failure seems fine (and is
45+
// not many sensible things to do on OOM. Panic seems fine (and is
4646
// what the old stack allocation did).
4747
let stack = match MemoryMap::new(size, &[MapReadable, MapWritable,
4848
MapNonStandardFlags(STACK_FLAGS)]) {

src/librand/distributions/exponential.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ pub struct Exp {
7373

7474
impl Exp {
7575
/// Construct a new `Exp` with the given shape parameter
76-
/// `lambda`. Fails if `lambda <= 0`.
76+
/// `lambda`. Panics if `lambda <= 0`.
7777
pub fn new(lambda: f64) -> Exp {
7878
assert!(lambda > 0.0, "Exp::new called with `lambda` <= 0");
7979
Exp { lambda_inverse: 1.0 / lambda }

src/librand/distributions/gamma.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl Gamma {
9595
/// Construct an object representing the `Gamma(shape, scale)`
9696
/// distribution.
9797
///
98-
/// Fails if `shape <= 0` or `scale <= 0`.
98+
/// Panics if `shape <= 0` or `scale <= 0`.
9999
pub fn new(shape: f64, scale: f64) -> Gamma {
100100
assert!(shape > 0.0, "Gamma::new called with shape <= 0");
101101
assert!(scale > 0.0, "Gamma::new called with scale <= 0");
@@ -208,7 +208,7 @@ enum ChiSquaredRepr {
208208

209209
impl ChiSquared {
210210
/// Create a new chi-squared distribution with degrees-of-freedom
211-
/// `k`. Fails if `k < 0`.
211+
/// `k`. Panics if `k < 0`.
212212
pub fn new(k: f64) -> ChiSquared {
213213
let repr = if k == 1.0 {
214214
DoFExactlyOne
@@ -261,7 +261,7 @@ pub struct FisherF {
261261

262262
impl FisherF {
263263
/// Create a new `FisherF` distribution, with the given
264-
/// parameter. Fails if either `m` or `n` are not positive.
264+
/// parameter. Panics if either `m` or `n` are not positive.
265265
pub fn new(m: f64, n: f64) -> FisherF {
266266
assert!(m > 0.0, "FisherF::new called with `m < 0`");
267267
assert!(n > 0.0, "FisherF::new called with `n < 0`");
@@ -302,7 +302,7 @@ pub struct StudentT {
302302

303303
impl StudentT {
304304
/// Create a new Student t distribution with `n` degrees of
305-
/// freedom. Fails if `n <= 0`.
305+
/// freedom. Panics if `n <= 0`.
306306
pub fn new(n: f64) -> StudentT {
307307
assert!(n > 0.0, "StudentT::new called with `n <= 0`");
308308
StudentT {

src/librand/distributions/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ pub struct WeightedChoice<'a, T:'a> {
113113
impl<'a, T: Clone> WeightedChoice<'a, T> {
114114
/// Create a new `WeightedChoice`.
115115
///
116-
/// Fails if:
116+
/// Panics if:
117117
/// - `v` is empty
118118
/// - the total weight is 0
119119
/// - the total weight is larger than a `uint` can contain.

src/librand/distributions/normal.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ pub struct Normal {
9090

9191
impl Normal {
9292
/// Construct a new `Normal` distribution with the given mean and
93-
/// standard deviation. Fails if `std_dev < 0`.
93+
/// standard deviation.
94+
///
95+
/// # Panics
96+
///
97+
/// Panics if `std_dev < 0`.
9498
pub fn new(mean: f64, std_dev: f64) -> Normal {
9599
assert!(std_dev >= 0.0, "Normal::new called with `std_dev` < 0");
96100
Normal {
@@ -132,7 +136,11 @@ pub struct LogNormal {
132136

133137
impl LogNormal {
134138
/// Construct a new `LogNormal` distribution with the given mean
135-
/// and standard deviation. Fails if `std_dev < 0`.
139+
/// and standard deviation.
140+
///
141+
/// # Panics
142+
///
143+
/// Panics if `std_dev < 0`.
136144
pub fn new(mean: f64, std_dev: f64) -> LogNormal {
137145
assert!(std_dev >= 0.0, "LogNormal::new called with `std_dev` < 0");
138146
LogNormal { norm: Normal::new(mean, std_dev) }

src/librand/distributions/range.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub struct Range<X> {
5555

5656
impl<X: SampleRange + PartialOrd> Range<X> {
5757
/// Create a new `Range` instance that samples uniformly from
58-
/// `[low, high)`. Fails if `low >= high`.
58+
/// `[low, high)`. Panics if `low >= high`.
5959
pub fn new(low: X, high: X) -> Range<X> {
6060
assert!(low < high, "Range::new called with `low >= high`");
6161
SampleRange::construct_range(low, high)

src/librand/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,18 @@ pub trait Rng {
204204
Generator { rng: self }
205205
}
206206

207-
/// Generate a random value in the range [`low`, `high`). Fails if
208-
/// `low >= high`.
207+
/// Generate a random value in the range [`low`, `high`).
209208
///
210209
/// This is a convenience wrapper around
211210
/// `distributions::Range`. If this function will be called
212211
/// repeatedly with the same arguments, one should use `Range`, as
213212
/// that will amortize the computations that allow for perfect
214213
/// uniformity, as they only happen on initialization.
215214
///
215+
/// # Panics
216+
///
217+
/// Panics if `low >= high`.
218+
///
216219
/// # Example
217220
///
218221
/// ```rust

0 commit comments

Comments
 (0)