Simplify code and better error messages.

This commit is contained in:
Stephen Chung
2020-12-28 14:21:13 +08:00
parent 5c813ca7c0
commit e481a8019d
11 changed files with 224 additions and 157 deletions

View File

@@ -812,6 +812,7 @@ impl Dynamic {
#[cfg(not(feature = "no_closure"))]
#[cfg(feature = "sync")]
Union::Shared(cell, _) => return cell.read().unwrap().clone().try_cast(),
_ => (),
}
@@ -903,7 +904,7 @@ impl Dynamic {
match self.0 {
Union::Variant(value, _) => (*value).as_box_any().downcast().map(|x| *x).ok(),
#[cfg(not(feature = "no_closure"))]
Union::Shared(_, _) => unreachable!(),
Union::Shared(_, _) => unreachable!("Union::Shared case should be already handled"),
_ => None,
}
}