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

seal the Diagnose trait #107

Merged
merged 3 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased

### Changed

- Sealed the `Diagnose` trait.
- Implementation of the `Default` trait for `Pointer` now doesn't constrain the lifetime.

## [0.7.1] 2025-02-16
Expand Down
7 changes: 6 additions & 1 deletion src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ pub(crate) use diagnostic_url;
/// An extension trait for `Result<_, E>`, where `E` is an implementation of
/// [`Diagnostic`], that converts `E` into [`Report<E>`](`Report`), yielding
/// `Result<_, Report<E>>`.
pub trait Diagnose<'s, T> {
pub trait Diagnose<'s, T>: private::Sealed {
/// The error type returned from `diagnose` and `diagnose_with`.
type Error: Diagnostic;

Expand Down Expand Up @@ -224,6 +224,11 @@ where
}
}

mod private {
pub trait Sealed {}
impl<T, E> Sealed for Result<T, E> {}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
Loading