From f1e83eb81879412e1de9898238ba58289bb6cb24 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Wed, 8 Jul 2020 22:58:41 +0200 Subject: Ensure Error trait implementations The anyhow crate requires that error types are error::Error, Send, Sync and 'static. This patch implements a simple static assertion that our Error type implements these traits. --- src/error.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/error.rs b/src/error.rs index 995741b..1aa1793 100644 --- a/src/error.rs +++ b/src/error.rs @@ -267,3 +267,22 @@ impl fmt::Display for LibraryError { }) } } + +// build our own static assertion that Error implements error::Error, Send, Sync, 'static + +struct Helper(T); + +trait Assert { + fn assert() -> bool; +} + +impl Assert for Helper { + fn assert() -> bool { + true + } +} + +#[allow(unused)] +fn assert_error_impl() { + let _ = Helper::::assert(); +} -- cgit v1.2.3