Skip to content

Commit 948d48e

Browse files
committed
Move description of the Error trait to its own doc-comment
… rather than the module’s.
1 parent 01d0be9 commit 948d48e

File tree

1 file changed

+25
-29
lines changed

1 file changed

+25
-29
lines changed

src/libstd/error.rs

+25-29
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,6 @@
99
// except according to those terms.
1010

1111
//! Traits for working with Errors.
12-
//!
13-
//! # The `Error` trait
14-
//!
15-
//! `Error` is a trait representing the basic expectations for error values,
16-
//! i.e. values of type `E` in [`Result<T, E>`]. At a minimum, errors must provide
17-
//! a description, but they may optionally provide additional detail (via
18-
//! [`Display`]) and cause chain information:
19-
//!
20-
//! ```
21-
//! use std::fmt::Display;
22-
//!
23-
//! trait Error: Display {
24-
//! fn description(&self) -> &str;
25-
//!
26-
//! fn cause(&self) -> Option<&Error> { None }
27-
//! }
28-
//! ```
29-
//!
30-
//! The [`cause`] method is generally used when errors cross "abstraction
31-
//! boundaries", i.e. when a one module must report an error that is "caused"
32-
//! by an error from a lower-level module. This setup makes it possible for the
33-
//! high-level module to provide its own errors that do not commit to any
34-
//! particular implementation, but also reveal some of its implementation for
35-
//! debugging via [`cause`] chains.
36-
//!
37-
//! [`Result<T, E>`]: ../result/enum.Result.html
38-
//! [`Display`]: ../fmt/trait.Display.html
39-
//! [`cause`]: trait.Error.html#method.cause
4012
4113
#![stable(feature = "rust1", since = "1.0.0")]
4214

@@ -63,7 +35,31 @@ use num;
6335
use str;
6436
use string;
6537

66-
/// Base functionality for all errors in Rust.
38+
/// `Error` is a trait representing the basic expectations for error values,
39+
/// i.e. values of type `E` in [`Result<T, E>`]. At a minimum, errors must provide
40+
/// a description, but they may optionally provide additional detail (via
41+
/// [`Display`]) and cause chain information:
42+
///
43+
/// ```
44+
/// use std::fmt::Display;
45+
///
46+
/// trait Error: Display {
47+
/// fn description(&self) -> &str;
48+
///
49+
/// fn cause(&self) -> Option<&Error> { None }
50+
/// }
51+
/// ```
52+
///
53+
/// The [`cause`] method is generally used when errors cross "abstraction
54+
/// boundaries", i.e. when a one module must report an error that is "caused"
55+
/// by an error from a lower-level module. This setup makes it possible for the
56+
/// high-level module to provide its own errors that do not commit to any
57+
/// particular implementation, but also reveal some of its implementation for
58+
/// debugging via [`cause`] chains.
59+
///
60+
/// [`Result<T, E>`]: ../result/enum.Result.html
61+
/// [`Display`]: ../fmt/trait.Display.html
62+
/// [`cause`]: trait.Error.html#method.cause
6763
#[stable(feature = "rust1", since = "1.0.0")]
6864
pub trait Error: Debug + Display {
6965
/// A short description of the error.

0 commit comments

Comments
 (0)