mirror of
https://github.com/encounter/rust-sdl2.git
synced 2026-07-10 21:18:41 -07:00
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:
+4
-1
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user