Merge branch 'master' into ruby-namespace

This commit is contained in:
Godfrey Chan 2017-06-02 17:12:01 -07:00 committed by Yehuda Katz
commit 38839481eb
2 changed files with 16 additions and 19 deletions

View File

@ -17,11 +17,7 @@ impl<'a> UncheckedValue<bool> for Value<'a> {
impl<'a> ToRust<bool> for CheckedValue<'a, bool> {
fn to_rust(self) -> bool {
if unsafe { self.inner.inner() == Qtrue } {
true
} else {
false
}
unsafe { self.inner.inner() == Qtrue }
}
}

View File

@ -109,20 +109,21 @@ impl ExceptionInfo {
}
pub fn from_any(any: Box<std::any::Any>) -> ExceptionInfo {
match any.downcast_ref::<ExceptionInfo>() {
Some(e) => *e,
None => {
match any.downcast_ref::<&'static str>() {
Some(e) => ExceptionInfo::with_message(e.to_string()),
None => {
match any.downcast_ref::<String>() {
Some(e) => ExceptionInfo::with_message(e.as_str()),
None => ExceptionInfo::with_message(format!("Unknown Error; err={:?}", any)),
}
}
}
}
}
any.downcast_ref::<ExceptionInfo>()
.map(|e| *e)
.or_else(||
any.downcast_ref::<&'static str>()
.map(|e| e.to_string())
.map(ExceptionInfo::with_message)
)
.or_else(||
any.downcast_ref::<String>()
.map(|e| e.as_str())
.map(ExceptionInfo::with_message)
)
.unwrap_or_else(||
ExceptionInfo::with_message(format!("Unknown Error; err={:?}", any))
)
}
pub fn message(&self) -> VALUE {