Skip to content

Commit 8ad9481

Browse files
committed
docs: add #[derive] to docs
1 parent 6b7f431 commit 8ad9481

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

error_mancer/src/lib.rs

+22
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,28 @@
101101
//! }
102102
//! ```
103103
//!
104+
//! ## Deriving traits for generated enum
105+
//! You can annotate the function with `#[derive]` to derive traits for the generated enum.
106+
//! Note that the `#[derive]` macro must be used after the `errors` macro. (techically in `impl`
107+
//! blocks the order doesnt matter, but we recommend using `#[derive]` after `errors` for consistency.)
108+
//! ```rust
109+
//! # use error_mancer::prelude::*;
110+
//! # use thiserror::Error;
111+
//! # #[derive(Error, Debug, Clone)]
112+
//! # #[error("1")]
113+
//! # struct Err1;
114+
//!
115+
//! #[errors(Err1)]
116+
//! #[derive(Clone)]
117+
//! fn foo() -> Result<(), _> {
118+
//! Ok(())
119+
//! }
120+
//!
121+
//! fn bar() {
122+
//! let _ = foo().clone();
123+
//! }
124+
//! ```
125+
//!
104126
//! ## Specifics and Implementation Details
105127
//!
106128
//! ### Error Type Overwriting

0 commit comments

Comments
 (0)