|
38 | 38 | //! # Details
|
39 | 39 | //!
|
40 | 40 | //! - Thiserror deliberately does not appear in your public API. You get the
|
41 |
| -//! same thing as if you had written an implementation of `std::error::Error` |
| 41 | +//! same thing as if you had written an implementation of [`std::error::Error`] |
42 | 42 | //! by hand, and switching from handwritten impls to thiserror or vice versa
|
43 | 43 | //! is not a breaking change.
|
44 | 44 | //!
|
45 | 45 | //! - Errors may be enums, structs with named fields, tuple structs, or unit
|
46 | 46 | //! structs.
|
47 | 47 | //!
|
48 |
| -//! - A `Display` impl is generated for your error if you provide |
| 48 | +//! - A [`Display`] impl is generated for your error if you provide |
49 | 49 | //! `#[error("...")]` messages on the struct or each variant of your enum, as
|
50 | 50 | //! shown above in the example.
|
51 | 51 | //!
|
|
96 | 96 | //! }
|
97 | 97 | //! ```
|
98 | 98 | //!
|
99 |
| -//! - A `From` impl is generated for each variant that contains a `#[from]` |
| 99 | +//! - A [`From`] impl is generated for each variant that contains a `#[from]` |
100 | 100 | //! attribute.
|
101 | 101 | //!
|
102 | 102 | //! The variant using `#[from]` must not contain any other fields beyond the
|
|
128 | 128 | //! # }
|
129 | 129 | //! ```
|
130 | 130 | //!
|
131 |
| -//! - The Error trait's `source()` method is implemented to return whichever |
| 131 | +//! - The Error trait's [`source()`] method is implemented to return whichever |
132 | 132 | //! field has a `#[source]` attribute or is named `source`, if any. This is
|
133 | 133 | //! for identifying the underlying lower level error that caused your error.
|
134 | 134 | //!
|
|
156 | 156 | //! # }
|
157 | 157 | //! ```
|
158 | 158 | //!
|
159 |
| -//! - The Error trait's `provide()` method is implemented to provide whichever |
| 159 | +//! - The Error trait's [`provide()`] method is implemented to provide whichever |
160 | 160 | //! field has a type named `Backtrace`, if any, as a
|
161 |
| -//! `std::backtrace::Backtrace`. Using `Backtrace` in errors requires a |
| 161 | +//! [`std::backtrace::Backtrace`]. Using `Backtrace` in errors requires a |
162 | 162 | //! nightly compiler with Rust version 1.73 or newer.
|
163 | 163 | //!
|
164 | 164 | //! ```rust
|
|
175 | 175 | //!
|
176 | 176 | //! - If a field is both a source (named `source`, or has `#[source]` or
|
177 | 177 | //! `#[from]` attribute) *and* is marked `#[backtrace]`, then the Error
|
178 |
| -//! trait's `provide()` method is forwarded to the source's `provide` so that |
| 178 | +//! trait's [`provide()`] method is forwarded to the source's `provide` so that |
179 | 179 | //! both layers of the error share the same backtrace. The `#[backtrace]`
|
180 | 180 | //! attribute requires a nightly compiler with Rust version 1.73 or newer.
|
181 | 181 | //!
|
|
207 | 207 | //! # };
|
208 | 208 | //! ```
|
209 | 209 | //!
|
210 |
| -//! - Errors may use `error(transparent)` to forward the source and Display |
| 210 | +//! - Errors may use `error(transparent)` to forward the source and [`Display`] |
211 | 211 | //! methods straight through to an underlying error without adding an
|
212 | 212 | //! additional message. This would be appropriate for enums that need an
|
213 | 213 | //! "anything else" variant.
|
|
255 | 255 | //! in application code.
|
256 | 256 | //!
|
257 | 257 | //! [`anyhow`]: https://github.com/dtolnay/anyhow
|
| 258 | +//! [`source()`]: std::error::Error::source |
| 259 | +//! [`provide()`]: std::error::Error::provide |
| 260 | +//! [`Display`]: std::fmt::Display |
258 | 261 |
|
259 | 262 | #![no_std]
|
260 | 263 | #![doc(html_root_url = "https://docs.rs/thiserror/2.0.12")]
|
|
0 commit comments