aboutsummaryrefslogtreecommitdiff
path: root/nitrocli/src/error.rs
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2019-01-11 01:30:24 +0000
committerDaniel Mueller <deso@posteo.net>2019-01-26 22:04:39 -0800
commit9d854fc5baad01d059acdb96fad82700042ef114 (patch)
tree842d276c2de5dfca2c70498eda63d6262043f32e /nitrocli/src/error.rs
parent77ff522ba2ebee17eb56f52921f127fba2fbd7fb (diff)
downloadnitrocli-9d854fc5baad01d059acdb96fad82700042ef114.tar.gz
nitrocli-9d854fc5baad01d059acdb96fad82700042ef114.tar.bz2
Implement From<&str> for Error
This patch implements From<&str> for Error so that we can use Error::from(s) as a shorthand for Error::Error(s.to_string()). It also replaces Error::Error with Error::from where possible.
Diffstat (limited to 'nitrocli/src/error.rs')
-rw-r--r--nitrocli/src/error.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/nitrocli/src/error.rs b/nitrocli/src/error.rs
index 78b8148..1346526 100644
--- a/nitrocli/src/error.rs
+++ b/nitrocli/src/error.rs
@@ -31,6 +31,12 @@ pub enum Error {
Error(String),
}
+impl From<&str> for Error {
+ fn from(s: &str) -> Error {
+ Error::Error(s.to_string())
+ }
+}
+
impl From<nitrokey::CommandError> for Error {
fn from(e: nitrokey::CommandError) -> Error {
Error::CommandError(None, e)