Panic with less ambiguous message if render target is already borrowed

It's better than seeing 'RefCell<T> already borrowed', in which case
you can't tell _which_ RefCell was borrowed.
This commit is contained in:
Dan Spencer
2015-01-27 10:59:15 -07:00
parent 4be211e7fa
commit 66e3ccc026
+4 -1
View File
@@ -248,7 +248,10 @@ impl Renderer {
pub fn render_target(&self) -> Option<RefMut<RenderTarget>> {
if self.render_target_supported() {
Some(self.render_target.borrow_mut())
match self.render_target.try_borrow_mut() {
Some(render_target) => Some(render_target),
None => panic!("Render target already borrowed")
}
} else {
None
}