summaryrefslogtreecommitdiff
path: root/src/error.rs
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2020-07-08 22:58:41 +0200
committerRobin Krahl <robin.krahl@ireas.org>2020-07-08 23:03:02 +0200
commitf1e83eb81879412e1de9898238ba58289bb6cb24 (patch)
tree1bba179f71828cb9e0004c82ed991fe22cddf3f2 /src/error.rs
parent3f402dc13530ce4de167bae843200cfbd72ed69b (diff)
downloadnitrokey-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.
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs19
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();
+}