-
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!(blanket_impls): impl
Diagnostic
for &T and Box<T>
Brings things in line with best practices as described in "Rust for Rustaceans" when it comes to "Ergonomic Trait Implementations" in Chapter 3. Practically means that people can pass more types to any functions taking either `dyn Diagnostic` or `impl Diagnostic`. BREAKING CHANGE: Added blanket impls may overlap with manual user impls. If these impls are just hacks to achieve the same as the blanket ones do, then they can simply be removed. If the impls for `T` and `&T` differ semantically, then the user would need to employ the newtype pattern to avoid overlap.
- Loading branch information
1 parent
ea4296d
commit a8cb8fa
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use miette::{Diagnostic, MietteDiagnostic}; | ||
|
||
fn assert_diagnostic<T: Diagnostic>() {} | ||
|
||
#[test] | ||
fn test_ref() { | ||
assert_diagnostic::<&MietteDiagnostic>() | ||
} | ||
|
||
#[test] | ||
fn test_box() { | ||
assert_diagnostic::<Box<MietteDiagnostic>>() | ||
} |