//! drop(file);
//! ```
//!
-//! If you *do* write that in Rust, the compiler will by give you a
+//! If you *do* write that in Rust, the compiler will give you a
//! warning (by default, controlled by the `unused_must_use` lint).
//!
//! You might instead, if you don't want to handle the error, simply
//! fn write_info(info: &Info) -> Result<(), IoError> {
//! let mut file = File::open_mode(&Path::new("my_best_friends.txt"), Open, Write);
//! // Early return on error
-//! match file.write_line(format!("name: {}", info.name).as_slice()) {
-//! Ok(_) => (),
-//! Err(e) => return Err(e)
+//! if let Err(e) = file.write_line(format!("name: {}", info.name).as_slice()) {
+//! return Err(e)
//! }
-//! match file.write_line(format!("age: {}", info.age).as_slice()) {
-//! Ok(_) => (),
-//! Err(e) => return Err(e)
+//! if let Err(e) = file.write_line(format!("age: {}", info.age).as_slice()) {
+//! return Err(e)
//! }
//! return file.write_line(format!("rating: {}", info.rating).as_slice());
//! }
//! makes it clear:
//!
//! ```
-//! # #![feature(macro_rules)]
//! macro_rules! try {
//! ($e:expr) => (match $e { Ok(e) => e, Err(e) => return Err(e) })
//! }
-//! # fn main() { }
//! ```
//!
//! `try!` is imported by the prelude, and is available everywhere.
use self::Result::{Ok, Err};
use clone::Clone;
-use fmt::Show;
+use fmt::Display;
use iter::{Iterator, IteratorExt, DoubleEndedIterator, FromIterator, ExactSizeIterator};
use ops::{FnMut, FnOnce};
use option::Option::{self, None, Some};
}
#[stable]
-impl<T, E: Show> Result<T, E> {
+impl<T, E: Display> Result<T, E> {
/// Unwraps a result, yielding the content of an `Ok`.
///
/// # Panics
match self {
Ok(t) => t,
Err(e) =>
- panic!("called `Result::unwrap()` on an `Err` value: {:?}", e)
+ panic!("called `Result::unwrap()` on an `Err` value: {}", e)
}
}
}
#[stable]
-impl<T: Show, E> Result<T, E> {
+impl<T: Display, E> Result<T, E> {
/// Unwraps a result, yielding the content of an `Err`.
///
/// # Panics
pub fn unwrap_err(self) -> E {
match self {
Ok(t) =>
- panic!("called `Result::unwrap_err()` on an `Ok` value: {:?}", t),
+ panic!("called `Result::unwrap_err()` on an `Ok` value: {}", t),
Err(e) => e
}
}
/// If an `Err` is encountered, it is immediately returned.
/// Otherwise, the folded value is returned.
#[inline]
-#[experimental]
+#[unstable]
pub fn fold<T,
V,
E,