Skip to content

Commit

Permalink
document that error(transparent) works with structs
Browse files Browse the repository at this point in the history
  • Loading branch information
matklad committed Sep 24, 2022
1 parent b37dc36 commit 765cd2a
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 765cd2a

Please sign in to comment.