// allocate some memory to use as scratch memory, we keep the
// length 0 so we can keep shallow copies of the contents of `v`
// without risking the dtors running on an object twice if
- // `compare` fails.
+ // `compare` panics.
let mut working_space = Vec::with_capacity(2 * len);
// these both are buffers of length `len`.
let mut buf_dat = working_space.as_mut_ptr();
///
/// # Panics
///
- /// Fails if the value is a `None` with a custom panic message provided by
+ /// Panics if the value is a `None` with a custom panic message provided by
/// `msg`.
///
/// # Example
///
/// ```{.should_fail}
/// let x: Option<&str> = None;
- /// x.expect("the world is ending"); // fails with `world is ending`
+ /// x.expect("the world is ending"); // panics with `world is ending`
/// ```
#[inline]
#[unstable = "waiting for conventions"]
///
/// On success returns `Ok(Matches)`. Use methods such as `opt_present`
/// `opt_str`, etc. to interrogate results.
-/// # Errors
+/// # Panics
///
/// Returns `Err(Fail_)` on failure: use the `Show` implementation of `Fail_` to display
/// information about it.
/// Note: Function was moved here from `std::str` because this module is the only place that
/// uses it, and because it was too specific for a general string function.
///
-/// #Failure:
+/// # Panics
///
-/// Fails during iteration if the string contains a non-whitespace
+/// Panics during iteration if the string contains a non-whitespace
/// sequence longer than the limit.
fn each_split_within<'a>(ss: &'a str, lim: uint, it: |&'a str| -> bool)
-> bool {
pub fn new(size: uint) -> Stack {
// Map in a stack. Eventually we might be able to handle stack
// allocation failure, which would fail to spawn the task. But there's
- // not many sensible things to do on OOM. Failure seems fine (and is
+ // not many sensible things to do on OOM. Panic seems fine (and is
// what the old stack allocation did).
let stack = match MemoryMap::new(size, &[MapReadable, MapWritable,
MapNonStandardFlags(STACK_FLAGS)]) {
impl Exp {
/// Construct a new `Exp` with the given shape parameter
- /// `lambda`. Fails if `lambda <= 0`.
+ /// `lambda`. Panics if `lambda <= 0`.
pub fn new(lambda: f64) -> Exp {
assert!(lambda > 0.0, "Exp::new called with `lambda` <= 0");
Exp { lambda_inverse: 1.0 / lambda }
/// Construct an object representing the `Gamma(shape, scale)`
/// distribution.
///
- /// Fails if `shape <= 0` or `scale <= 0`.
+ /// Panics if `shape <= 0` or `scale <= 0`.
pub fn new(shape: f64, scale: f64) -> Gamma {
assert!(shape > 0.0, "Gamma::new called with shape <= 0");
assert!(scale > 0.0, "Gamma::new called with scale <= 0");
impl ChiSquared {
/// Create a new chi-squared distribution with degrees-of-freedom
- /// `k`. Fails if `k < 0`.
+ /// `k`. Panics if `k < 0`.
pub fn new(k: f64) -> ChiSquared {
let repr = if k == 1.0 {
DoFExactlyOne
impl FisherF {
/// Create a new `FisherF` distribution, with the given
- /// parameter. Fails if either `m` or `n` are not positive.
+ /// parameter. Panics if either `m` or `n` are not positive.
pub fn new(m: f64, n: f64) -> FisherF {
assert!(m > 0.0, "FisherF::new called with `m < 0`");
assert!(n > 0.0, "FisherF::new called with `n < 0`");
impl StudentT {
/// Create a new Student t distribution with `n` degrees of
- /// freedom. Fails if `n <= 0`.
+ /// freedom. Panics if `n <= 0`.
pub fn new(n: f64) -> StudentT {
assert!(n > 0.0, "StudentT::new called with `n <= 0`");
StudentT {
impl<'a, T: Clone> WeightedChoice<'a, T> {
/// Create a new `WeightedChoice`.
///
- /// Fails if:
+ /// Panics if:
/// - `v` is empty
/// - the total weight is 0
/// - the total weight is larger than a `uint` can contain.
impl Normal {
/// Construct a new `Normal` distribution with the given mean and
- /// standard deviation. Fails if `std_dev < 0`.
+ /// standard deviation.
+ ///
+ /// # Panics
+ ///
+ /// Panics if `std_dev < 0`.
pub fn new(mean: f64, std_dev: f64) -> Normal {
assert!(std_dev >= 0.0, "Normal::new called with `std_dev` < 0");
Normal {
impl LogNormal {
/// Construct a new `LogNormal` distribution with the given mean
- /// and standard deviation. Fails if `std_dev < 0`.
+ /// and standard deviation.
+ ///
+ /// # Panics
+ ///
+ /// Panics if `std_dev < 0`.
pub fn new(mean: f64, std_dev: f64) -> LogNormal {
assert!(std_dev >= 0.0, "LogNormal::new called with `std_dev` < 0");
LogNormal { norm: Normal::new(mean, std_dev) }
impl<X: SampleRange + PartialOrd> Range<X> {
/// Create a new `Range` instance that samples uniformly from
- /// `[low, high)`. Fails if `low >= high`.
+ /// `[low, high)`. Panics if `low >= high`.
pub fn new(low: X, high: X) -> Range<X> {
assert!(low < high, "Range::new called with `low >= high`");
SampleRange::construct_range(low, high)
Generator { rng: self }
}
- /// Generate a random value in the range [`low`, `high`). Fails if
- /// `low >= high`.
+ /// Generate a random value in the range [`low`, `high`).
///
/// This is a convenience wrapper around
/// `distributions::Range`. If this function will be called
/// that will amortize the computations that allow for perfect
/// uniformity, as they only happen on initialization.
///
+ /// # Panics
+ ///
+ /// Panics if `low >= high`.
+ ///
/// # Example
///
/// ```rust
// the encoded EBML (normally). This is just for
// efficiency. When debugging, though, we can emit such
// labels and then they will be checked by decoder to
- // try and check failures more quickly.
+ // try and check panics more quickly.
if DEBUG { self.wr_tagged_str(EsLabel as uint, label) }
else { Ok(()) }
}
Jump(InstIdx),
// Jumps to the instruction at the first index given. If that leads to
- // a failing state, then the instruction at the second index given is
+ // a panic state, then the instruction at the second index given is
// tried.
Split(InstIdx, InstIdx),
}
}
/**
- * Returns the module node. Fails if this node does not have a module
+ * Returns the module node. Panics if this node does not have a module
* definition.
*/
fn get_module(&self) -> Rc<Module> {
* corresponding to the innermost block ID and returns the name bindings
* as well as the newly-created parent.
*
- * If this node does not have a module definition and we are not inside
- * a block, fails.
+ * # Panics
+ *
+ * Panics if this node does not have a module definition and we are not inside
+ * a block.
*/
fn add_child(&self,
name: Name,
return Success(());
}
- // Resolves a glob import. Note that this function cannot fail; it either
+ // Resolves a glob import. Note that this function cannot panic; it either
// succeeds or bails out (as importing * from an empty module or a module
// that exports nothing is valid).
fn resolve_glob_import(&mut self,
}
}
-// Return the smallest part of ty which is unsized. Fails if ty is sized.
+// Return the smallest part of `ty` which is unsized. Fails if `ty` is sized.
// 'Smallest' here means component of the static representation of the type; not
// the size of an object at runtime.
pub fn unsized_part_of_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
}
// Look up the list of field names and IDs for a given struct.
-// Fails if the id is not bound to a struct.
+// Panics if the id is not bound to a struct.
pub fn lookup_struct_fields(cx: &ctxt, did: ast::DefId) -> Vec<field_ty> {
if did.krate == ast::LOCAL_CRATE {
let struct_fields = cx.struct_fields.borrow();
}
/// Given the head of a `for` expression, looks up the `next` method in the
-/// `Iterator` trait. Fails if the expression does not implement `next`.
+/// `Iterator` trait. Panics if the expression does not implement `next`.
///
/// The return type of this function represents the concrete element type
/// `A` in the type `Iterator<A>` that the method returns.
}
/// Prints version information and returns None on success or an error
-/// message on failure.
+/// message on panic.
pub fn version(binary: &str, matches: &getopts::Matches) -> Option<String> {
let verbose = match matches.opt_str("version").as_ref().map(|s| s.as_slice()) {
None => false,
metadata::loader::list_file_metadata(sess.target.target.options.is_like_osx, path, out)
}
-/// Run a procedure which will detect failures in the compiler and print nicer
+/// Run a procedure which will detect panics in the compiler and print nicer
/// error messages rather than just failing the test.
///
/// The diagnostic emitter yielded to the procedure should be used for reporting
}
// Panic so the process returns a failure code, but don't pollute the
- // output with some unnecessary failure messages, we've already
+ // output with some unnecessary panic messages, we've already
// printed everything that we needed to.
io::stdio::set_stderr(box io::util::NullWriter);
panic!();
/// Check if convertible to ascii
fn is_ascii(&self) -> bool;
- /// Take ownership and cast to an ascii vector. Fail on non-ASCII input.
+ /// Take ownership and cast to an ascii vector.
+ /// # Panics
+ ///
+ /// Panic on non-ASCII input.
#[inline]
fn into_ascii(self) -> Vec<Ascii> {
assert!(self.is_ascii());
impl<T> CVec<T> {
/// Create a `CVec` from a raw pointer to a buffer with a given length.
///
- /// Fails if the given pointer is null. The returned vector will not attempt
+ /// Panics if the given pointer is null. The returned vector will not attempt
/// to deallocate the vector when dropped.
///
/// # Arguments
/// Create a `CVec` from a foreign buffer, with a given length,
/// and a function to run upon destruction.
///
- /// Fails if the given pointer is null.
+ /// Panics if the given pointer is null.
///
/// # Arguments
///
//!
//! This module contains the implementation of a Windows specific console TTY.
//! Also converts between UTF-16 and UTF-8. Windows has very poor support for
-//! UTF-8 and some functions will fail. In particular ReadFile and ReadConsole
-//! will fail when the codepage is set to UTF-8 and a Unicode character is
+//! UTF-8 and some functions will panic. In particular ReadFile and ReadConsole
+//! will panic when the codepage is set to UTF-8 and a Unicode character is
//! entered.
//!
//! FIXME
pub fn is_tty(fd: c_int) -> bool {
let mut out: DWORD = 0;
- // If this function doesn't fail then fd is a TTY
+ // If this function doesn't panic then fd is a TTY
match unsafe { GetConsoleMode(get_osfhandle(fd) as HANDLE,
&mut out as LPDWORD) } {
0 => false,
impl Duration {
/// Makes a new `Duration` with given number of weeks.
/// Equivalent to `Duration::seconds(weeks * 7 * 24 * 60 * 60), with overflow checks.
- /// Fails when the duration is out of bounds.
+ /// Panics when the duration is out of bounds.
#[inline]
pub fn weeks(weeks: i64) -> Duration {
let secs = weeks.checked_mul(SECS_PER_WEEK).expect("Duration::weeks out of bounds");
/// Makes a new `Duration` with given number of days.
/// Equivalent to `Duration::seconds(days * 24 * 60 * 60)` with overflow checks.
- /// Fails when the duration is out of bounds.
+ /// Panics when the duration is out of bounds.
#[inline]
pub fn days(days: i64) -> Duration {
let secs = days.checked_mul(SECS_PER_DAY).expect("Duration::days out of bounds");
/// Makes a new `Duration` with given number of hours.
/// Equivalent to `Duration::seconds(hours * 60 * 60)` with overflow checks.
- /// Fails when the duration is out of bounds.
+ /// Panics when the duration is out of bounds.
#[inline]
pub fn hours(hours: i64) -> Duration {
let secs = hours.checked_mul(SECS_PER_HOUR).expect("Duration::hours ouf of bounds");
/// Makes a new `Duration` with given number of minutes.
/// Equivalent to `Duration::seconds(minutes * 60)` with overflow checks.
- /// Fails when the duration is out of bounds.
+ /// Panics when the duration is out of bounds.
#[inline]
pub fn minutes(minutes: i64) -> Duration {
let secs = minutes.checked_mul(SECS_PER_MINUTE).expect("Duration::minutes out of bounds");
}
/// Makes a new `Duration` with given number of seconds.
- /// Fails when the duration is more than `i64::MAX` milliseconds
+ /// Panics when the duration is more than `i64::MAX` milliseconds
/// or less than `i64::MIN` milliseconds.
#[inline]
pub fn seconds(seconds: i64) -> Duration {