diff --git a/src/error.rs b/src/error.rs index a11d84b..9c9f6f7 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,6 +1,7 @@ use std::fmt; use std::sync::Arc; -use std::error; +use std::error::Error as StdError; +use std::result::Result as StdResult; #[derive(Debug, Clone)] pub enum Error { @@ -29,10 +30,10 @@ pub enum Error { CallbackError(String, Arc), /// Any custom external error type, mostly useful for returning external error types from /// callbacks. - ExternalError(Arc), + ExternalError(Arc), } -pub type Result = ::std::result::Result; +pub type Result = StdResult; impl fmt::Display for Error { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { @@ -61,7 +62,7 @@ impl fmt::Display for Error { } } -impl error::Error for Error { +impl StdError for Error { fn description(&self) -> &str { match *self { Error::SyntaxError(_) => "lua syntax error", @@ -79,7 +80,7 @@ impl error::Error for Error { } } - fn cause(&self) -> Option<&error::Error> { + fn cause(&self) -> Option<&StdError> { match *self { Error::CallbackError(_, ref cause) => Some(cause.as_ref()), Error::ExternalError(ref err) => err.cause(), @@ -89,7 +90,7 @@ impl error::Error for Error { } impl Error { - pub fn external(err: T) -> Error { + pub fn external(err: T) -> Error { Error::ExternalError(Arc::new(err)) } } @@ -100,11 +101,11 @@ pub trait ExternalError { impl ExternalError for E where - E: Into>, + E: Into>, { fn to_lua_err(self) -> Error { #[derive(Debug)] - struct WrapError(Box); + struct WrapError(Box); impl fmt::Display for WrapError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -112,7 +113,7 @@ where } } - impl error::Error for WrapError { + impl StdError for WrapError { fn description(&self) -> &str { self.0.description() } @@ -126,7 +127,7 @@ pub trait ExternalResult { fn to_lua_err(self) -> Result; } -impl ExternalResult for ::std::result::Result +impl ExternalResult for StdResult where E: ExternalError, { diff --git a/src/multi.rs b/src/multi.rs index bca9386..11c13fc 100644 --- a/src/multi.rs +++ b/src/multi.rs @@ -1,3 +1,5 @@ +use std::result::{Result as StdResult}; + use hlist_macro::{HNil, HCons}; use error::*; @@ -17,7 +19,7 @@ impl<'lua> FromLuaMulti<'lua> for () { /// Result is convertible to `MultiValue` following the common lua idiom of returning the result /// on success, or in the case of an error, returning nil followed by the error -impl<'lua, T: ToLua<'lua>, E: ToLua<'lua>> ToLuaMulti<'lua> for ::std::result::Result { +impl<'lua, T: ToLua<'lua>, E: ToLua<'lua>> ToLuaMulti<'lua> for StdResult { fn to_lua_multi(self, lua: &'lua Lua) -> Result> { let mut result = MultiValue::new();