Skip to content

Commit

Permalink
Remove main() in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
phungleson committed Oct 2, 2018
1 parent a7cc1fc commit 30f2e96
Showing 1 changed file with 30 additions and 46 deletions.
76 changes: 30 additions & 46 deletions src/libstd/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,10 @@ impl<'a, E: Error + 'a> From<E> for Box<dyn Error + 'a> {
/// }
/// }
///
/// fn main() {
/// let an_error = AnError;
/// assert!(0 == mem::size_of_val(&an_error));
/// let a_boxed_error = Box::<Error>::from(an_error);
/// assert!(mem::size_of::<Box<dyn Error>>() == mem::size_of_val(&a_boxed_error))
/// }
/// let an_error = AnError;
/// assert!(0 == mem::size_of_val(&an_error));
/// let a_boxed_error = Box::<Error>::from(an_error);
/// assert!(mem::size_of::<Box<dyn Error>>() == mem::size_of_val(&a_boxed_error))
/// ```
fn from(err: E) -> Box<dyn Error + 'a> {
Box::new(err)
Expand Down Expand Up @@ -219,13 +217,11 @@ impl<'a, E: Error + Send + Sync + 'a> From<E> for Box<dyn Error + Send + Sync +
///
/// unsafe impl Sync for AnError {}
///
/// fn main() {
/// let an_error = AnError;
/// assert!(0 == mem::size_of_val(&an_error));
/// let a_boxed_error = Box::<Error + Send + Sync>::from(an_error);
/// assert!(
/// mem::size_of::<Box<dyn Error + Send + Sync>>() == mem::size_of_val(&a_boxed_error))
/// }
/// let an_error = AnError;
/// assert!(0 == mem::size_of_val(&an_error));
/// let a_boxed_error = Box::<Error + Send + Sync>::from(an_error);
/// assert!(
/// mem::size_of::<Box<dyn Error + Send + Sync>>() == mem::size_of_val(&a_boxed_error))
/// ```
fn from(err: E) -> Box<dyn Error + Send + Sync + 'a> {
Box::new(err)
Expand All @@ -242,12 +238,10 @@ impl From<String> for Box<dyn Error + Send + Sync> {
/// use std::error::Error;
/// use std::mem;
///
/// fn main() {
/// let a_string_error = "a string error".to_string();
/// let a_boxed_error = Box::<Error + Send + Sync>::from(a_string_error);
/// assert!(
/// mem::size_of::<Box<dyn Error + Send + Sync>>() == mem::size_of_val(&a_boxed_error))
/// }
/// let a_string_error = "a string error".to_string();
/// let a_boxed_error = Box::<Error + Send + Sync>::from(a_string_error);
/// assert!(
/// mem::size_of::<Box<dyn Error + Send + Sync>>() == mem::size_of_val(&a_boxed_error))
/// ```
fn from(err: String) -> Box<dyn Error + Send + Sync> {
#[derive(Debug)]
Expand Down Expand Up @@ -277,11 +271,9 @@ impl From<String> for Box<dyn Error> {
/// use std::error::Error;
/// use std::mem;
///
/// fn main() {
/// let a_string_error = "a string error".to_string();
/// let a_boxed_error = Box::<Error>::from(a_string_error);
/// assert!(mem::size_of::<Box<dyn Error>>() == mem::size_of_val(&a_boxed_error))
/// }
/// let a_string_error = "a string error".to_string();
/// let a_boxed_error = Box::<Error>::from(a_string_error);
/// assert!(mem::size_of::<Box<dyn Error>>() == mem::size_of_val(&a_boxed_error))
/// ```
fn from(str_err: String) -> Box<dyn Error> {
let err1: Box<dyn Error + Send + Sync> = From::from(str_err);
Expand All @@ -300,12 +292,10 @@ impl<'a, 'b> From<&'b str> for Box<dyn Error + Send + Sync + 'a> {
/// use std::error::Error;
/// use std::mem;
///
/// fn main() {
/// let a_str_error = "a str error";
/// let a_boxed_error = Box::<Error + Send + Sync>::from(a_str_error);
/// assert!(
/// mem::size_of::<Box<dyn Error + Send + Sync>>() == mem::size_of_val(&a_boxed_error))
/// }
/// let a_str_error = "a str error";
/// let a_boxed_error = Box::<Error + Send + Sync>::from(a_str_error);
/// assert!(
/// mem::size_of::<Box<dyn Error + Send + Sync>>() == mem::size_of_val(&a_boxed_error))
/// ```
fn from(err: &'b str) -> Box<dyn Error + Send + Sync + 'a> {
From::from(String::from(err))
Expand All @@ -322,11 +312,9 @@ impl<'a> From<&'a str> for Box<dyn Error> {
/// use std::error::Error;
/// use std::mem;
///
/// fn main() {
/// let a_str_error = "a str error";
/// let a_boxed_error = Box::<Error>::from(a_str_error);
/// assert!(mem::size_of::<Box<dyn Error>>() == mem::size_of_val(&a_boxed_error))
/// }
/// let a_str_error = "a str error";
/// let a_boxed_error = Box::<Error>::from(a_str_error);
/// assert!(mem::size_of::<Box<dyn Error>>() == mem::size_of_val(&a_boxed_error))
/// ```
fn from(err: &'a str) -> Box<dyn Error> {
From::from(String::from(err))
Expand All @@ -344,12 +332,10 @@ impl<'a, 'b> From<Cow<'b, str>> for Box<dyn Error + Send + Sync + 'a> {
/// use std::mem;
/// use std::borrow::Cow;
///
/// fn main() {
/// let a_cow_str_error = Cow::from("a str error");
/// let a_boxed_error = Box::<Error + Send + Sync>::from(a_cow_str_error);
/// assert!(
/// mem::size_of::<Box<dyn Error + Send + Sync>>() == mem::size_of_val(&a_boxed_error))
/// }
/// let a_cow_str_error = Cow::from("a str error");
/// let a_boxed_error = Box::<Error + Send + Sync>::from(a_cow_str_error);
/// assert!(
/// mem::size_of::<Box<dyn Error + Send + Sync>>() == mem::size_of_val(&a_boxed_error))
/// ```
fn from(err: Cow<'b, str>) -> Box<dyn Error + Send + Sync + 'a> {
From::from(String::from(err))
Expand All @@ -367,11 +353,9 @@ impl<'a> From<Cow<'a, str>> for Box<dyn Error> {
/// use std::mem;
/// use std::borrow::Cow;
///
/// fn main() {
/// let a_cow_str_error = Cow::from("a str error");
/// let a_boxed_error = Box::<Error>::from(a_cow_str_error);
/// assert!(mem::size_of::<Box<dyn Error>>() == mem::size_of_val(&a_boxed_error))
/// }
/// let a_cow_str_error = Cow::from("a str error");
/// let a_boxed_error = Box::<Error>::from(a_cow_str_error);
/// assert!(mem::size_of::<Box<dyn Error>>() == mem::size_of_val(&a_boxed_error))
/// ```
fn from(err: Cow<'a, str>) -> Box<dyn Error> {
From::from(String::from(err))
Expand Down

0 comments on commit 30f2e96

Please sign in to comment.