Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document that error(transparent) works with structs #195

Merged
merged 1 commit into from Sep 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/lib.rs
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