diff options
author | Robin Krahl <robin.krahl@ireas.org> | 2020-07-08 22:58:41 +0200 |
---|---|---|
committer | Robin Krahl <robin.krahl@ireas.org> | 2020-07-08 23:03:02 +0200 |
commit | f1e83eb81879412e1de9898238ba58289bb6cb24 (patch) | |
tree | 1bba179f71828cb9e0004c82ed991fe22cddf3f2 | |
parent | 3f402dc13530ce4de167bae843200cfbd72ed69b (diff) | |
download | nitrokey-rs-f1e83eb81879412e1de9898238ba58289bb6cb24.tar.gz nitrokey-rs-f1e83eb81879412e1de9898238ba58289bb6cb24.tar.bz2 |
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.
-rw-r--r-- | src/error.rs | 19 |
1 files changed, 19 insertions, 0 deletions
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>(T); + +trait Assert { + fn assert() -> bool; +} + +impl<T: error::Error + Send + Sync + 'static> Assert for Helper<T> { + fn assert() -> bool { + true + } +} + +#[allow(unused)] +fn assert_error_impl() { + let _ = Helper::<Error>::assert(); +} |