Cleanup downcast code

This commit is contained in:
Godfrey Chan 2017-09-26 13:02:31 -04:00
parent 9b638ac151
commit b9f090ed28
2 changed files with 4 additions and 5 deletions

View File

@ -24,11 +24,11 @@ impl Error {
}
pub fn from_any(any: Box<any::Any>) -> Error {
any.downcast_ref::<Error>()
any.downcast::<Error>()
.map(|e| *e)
.or_else(|| any.downcast_ref::<&'static str>().map(|e| e.to_error()))
.or_else(|| any.downcast_ref::<String>().map(|e| e.as_str().to_error()))
.unwrap_or_else(|| format!("Unknown Error (caused by `{:?}`)", any).to_error())
.or_else(|any| any.downcast::<&str>().map(|e| e.to_error()))
.or_else(|any| any.downcast::<String>().map(|e| e.to_error()))
.unwrap_or_else(|any| format!("Unknown Error (caused by `{:?}`)", any).to_error())
}
pub fn with_class(self, class: Class) -> Error {

View File

@ -6,7 +6,6 @@ macro_rules! codegen_init {
pub extern "C" fn Init_native() {
$crate::sys::check_version();
$(
codegen_class_binding!($class, $class);
)*