From 5b9b1591848303e5fa168d14ba7cd10764628a53 Mon Sep 17 00:00:00 2001 From: David Ross Date: Thu, 8 Jun 2017 22:47:34 -0700 Subject: [PATCH] Implement Clone and AsRef for Error. --- src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 214dace..ba26334 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -65,7 +65,7 @@ pub struct DB { /// A simple wrapper round a string, used for errors reported from /// ffi calls. -#[derive(Debug, PartialEq)] +#[derive(Debug, Clone, PartialEq)] pub struct Error { message: String, } @@ -80,6 +80,12 @@ impl Error { } } +impl AsRef for Error { + fn as_ref(&self) -> &str { + &self.message + } +} + impl From for String { fn from(e: Error) -> String { e.message