Skip to content

Commit

Permalink
Touch up PR 195
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Sep 25, 2022
1 parent 8e8e41d commit 5271eb3
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,22 @@
//! }
//! ```
//!
//! Another use-case is making semver-resilient opaque error types:
//! Another use case is hiding implementation details of an error
//! representation behind an opaque error type, so that the representation is
//! able to evolve without breaking the crate's public API.
//!
//! ```
//! # use thiserror::Error;
//! /// `LibError` is public, but opaque and easy to keep compatible.
//! // PublicError is public, but opaque and easy to keep compatible.
//! #[derive(Error, Debug)]
//! #[error(transparent)]
//! pub struct LibError(#[from] ErrorRepr);
//! pub struct PublicError(#[from] ErrorRepr);
//!
//! /// `ErrorRepr` is private and easy to change.
//! impl PublicError {
//! // Accessors for anything we do want to expose publicly.
//! }
//!
//! // Private and free to change across minor version of the crate.
//! #[derive(Error, Debug)]
//! enum ErrorRepr {
//! # /*
Expand Down

0 comments on commit 5271eb3

Please sign in to comment.