Skip to content
Myr

Test derive(Error) in docs using thiserror

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Tolnay · committed by David Tolnay · parent 284dec5 · Browse files · 1 file+10 added−34 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+10 added−34 removed

  • other:+10 added−34 removed

1 file+10 added−34 removed

modified:src/macros.rs+10 added-34 removed
22 unmodified lines
23/// ```24///25/// ```26/// # use anyhow::{bail, Result};27/// # use std::fmt::{self, Display};27/// # use thiserror::Error;28/// #29/// # #[derive(Debug)]30/// # enum ScienceError {31/// # RecursionLimitExceeded,32/// # }33/// #34/// # impl std::error::Error for ScienceError {}35/// #36/// # impl Display for ScienceError {37/// # fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {38/// # unimplemented!()39/// # }40/// # }41/// #29/// # const MAX_DEPTH: usize = 1;30/// #44/// # const IGNORE: &str = stringify! {31/// #[derive(Error, Debug)]32/// enum ScienceError {47/// #[error(display = "recursion limit exceeded")]33/// #[error("recursion limit exceeded")]34/// RecursionLimitExceeded,35/// # #[error("...")]36/// # More = (stringify! {37/// ...38/// # }, 1).1,39/// }51/// # };40///41/// # fn main() -> Result<()> {42/// # let depth = 0;43/// #
38 unmodified lines
82/// ```83///84/// ```85/// # use anyhow::{ensure, Result};98/// # use std::fmt::{self, Display};86/// # use thiserror::Error;87/// #100/// # #[derive(Debug)]101/// # enum ScienceError {102/// # RecursionLimitExceeded,103/// # }104/// #105/// # impl std::error::Error for ScienceError {}106/// #107/// # impl Display for ScienceError {108/// # fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {109/// # unimplemented!()110/// # }111/// # }112/// #88/// # const MAX_DEPTH: usize = 1;89/// #115/// # const IGNORE: &str = stringify! {90/// #[derive(Error, Debug)]91/// enum ScienceError {118/// #[error(display = "recursion limit exceeded")]92/// #[error("recursion limit exceeded")]93/// RecursionLimitExceeded,94/// # #[error("...")]95/// # More = (stringify! {96/// ...97/// # }, 1).1,98/// }122/// # };99///100/// # fn main() -> Result<()> {101/// # let depth = 0;102/// #
62 unmodified lines