Skip to content

Commit

Permalink
Merge pull request #195 from matklad/error-transparent
Browse files Browse the repository at this point in the history
document that `error(transparent)` works with structs
  • Loading branch information
dtolnay authored Sep 25, 2022
2 parents c79b023 + 765cd2a commit 8e8e41d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,24 @@
//! }
//! ```
//!
//! Another use-case is making semver-resilient opaque error types:
//!
//! ```
//! # use thiserror::Error;
//! /// `LibError` is public, but opaque and easy to keep compatible.
//! #[derive(Error, Debug)]
//! #[error(transparent)]
//! pub struct LibError(#[from] ErrorRepr);
//!
//! /// `ErrorRepr` is private and easy to change.
//! #[derive(Error, Debug)]
//! enum ErrorRepr {
//! # /*
//! ...
//! # */
//! }
//! ```
//!
//! - See also the [`anyhow`] library for a convenient single error type to use
//! in application code.
//!
Expand Down

0 comments on commit 8e8e41d

Please sign in to comment.