Skip to content

Add some missing commas and missing titles/formatting #32854

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 12, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 44 additions & 3 deletions src/libcore/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//! # #[allow(dead_code)]
//! enum Result<T, E> {
//! Ok(T),
//! Err(E)
//! Err(E),
//! }
//! ```
//!
Expand All @@ -39,7 +39,7 @@
//! None => Err("invalid header length"),
//! Some(&1) => Ok(Version::Version1),
//! Some(&2) => Ok(Version::Version2),
//! Some(_) => Err("invalid version")
//! Some(_) => Err("invalid version"),
//! }
//! }
//!
Expand Down Expand Up @@ -254,7 +254,7 @@ pub enum Result<T, E> {

/// Contains the error value
#[stable(feature = "rust1", since = "1.0.0")]
Err(#[stable(feature = "rust1", since = "1.0.0")] E)
Err(#[stable(feature = "rust1", since = "1.0.0")] E),
}

/////////////////////////////////////////////////////////////////////////////
Expand All @@ -270,6 +270,8 @@ impl<T, E> Result<T, E> {
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// let x: Result<i32, &str> = Ok(-3);
/// assert_eq!(x.is_ok(), true);
Expand All @@ -290,6 +292,8 @@ impl<T, E> Result<T, E> {
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// let x: Result<i32, &str> = Ok(-3);
/// assert_eq!(x.is_err(), false);
Expand All @@ -314,6 +318,8 @@ impl<T, E> Result<T, E> {
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// let x: Result<u32, &str> = Ok(2);
/// assert_eq!(x.ok(), Some(2));
Expand All @@ -337,6 +343,8 @@ impl<T, E> Result<T, E> {
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// let x: Result<u32, &str> = Ok(2);
/// assert_eq!(x.err(), None);
Expand All @@ -362,6 +370,10 @@ impl<T, E> Result<T, E> {
/// Produces a new `Result`, containing a reference
/// into the original, leaving the original in place.
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// let x: Result<u32, &str> = Ok(2);
/// assert_eq!(x.as_ref(), Ok(&2));
Expand All @@ -380,6 +392,10 @@ impl<T, E> Result<T, E> {

/// Converts from `Result<T, E>` to `Result<&mut T, &mut E>`
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// fn mutate(r: &mut Result<i32, i32>) {
/// match r.as_mut() {
Expand Down Expand Up @@ -445,6 +461,8 @@ impl<T, E> Result<T, E> {
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// fn stringify(x: u32) -> String { format!("error code: {}", x) }
///
Expand All @@ -471,6 +489,8 @@ impl<T, E> Result<T, E> {
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// let x: Result<u32, &str> = Ok(7);
/// assert_eq!(x.iter().next(), Some(&7));
Expand All @@ -488,6 +508,8 @@ impl<T, E> Result<T, E> {
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// let mut x: Result<u32, &str> = Ok(7);
/// match x.iter_mut().next() {
Expand All @@ -513,6 +535,8 @@ impl<T, E> Result<T, E> {
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// let x: Result<u32, &str> = Ok(2);
/// let y: Result<&str, &str> = Err("late error");
Expand Down Expand Up @@ -545,6 +569,8 @@ impl<T, E> Result<T, E> {
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// fn sq(x: u32) -> Result<u32, u32> { Ok(x * x) }
/// fn err(x: u32) -> Result<u32, u32> { Err(x) }
Expand All @@ -567,6 +593,8 @@ impl<T, E> Result<T, E> {
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// let x: Result<u32, &str> = Ok(2);
/// let y: Result<u32, &str> = Err("late error");
Expand Down Expand Up @@ -599,6 +627,8 @@ impl<T, E> Result<T, E> {
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// fn sq(x: u32) -> Result<u32, u32> { Ok(x * x) }
/// fn err(x: u32) -> Result<u32, u32> { Err(x) }
Expand All @@ -622,6 +652,8 @@ impl<T, E> Result<T, E> {
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// let optb = 2;
/// let x: Result<u32, &str> = Ok(9);
Expand All @@ -644,6 +676,8 @@ impl<T, E> Result<T, E> {
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// fn count(x: &str) -> usize { x.len() }
///
Expand All @@ -670,6 +704,8 @@ impl<T, E: fmt::Debug> Result<T, E> {
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// let x: Result<u32, &str> = Ok(2);
/// assert_eq!(x.unwrap(), 2);
Expand All @@ -696,6 +732,9 @@ impl<T, E: fmt::Debug> Result<T, E> {
/// passed message, and the content of the `Err`.
///
/// # Examples
///
/// Basic usage:
///
/// ```{.should_panic}
/// let x: Result<u32, &str> = Err("emergency failure");
/// x.expect("Testing expect"); // panics with `Testing expect: emergency failure`
Expand Down Expand Up @@ -759,6 +798,8 @@ impl<T, E> IntoIterator for Result<T, E> {
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// let x: Result<u32, &str> = Ok(5);
/// let v: Vec<u32> = x.into_iter().collect();
Expand Down