Skip to content

Commit 418fdf2

Browse files
committed
Updated Renderer::copy return type to match Renderer::copy_ex
1 parent 3c62e22 commit 418fdf2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/sdl2/render.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,8 @@ impl<'a> Renderer<'a> {
777777
/// # Panics
778778
/// Panics if drawing fails for any reason (e.g. driver failure),
779779
/// or if the provided texture does not belong to the renderer.
780-
pub fn copy(&mut self, texture: &Texture, src: Option<Rect>, dst: Option<Rect>) {
780+
pub fn copy(&mut self, texture: &Texture, src: Option<Rect>, dst: Option<Rect>)
781+
-> Result<(), String> {
781782
texture.check_renderer();
782783

783784
let ret = unsafe {
@@ -796,7 +797,9 @@ impl<'a> Renderer<'a> {
796797
};
797798

798799
if ret != 0 {
799-
panic!("Error copying texture: {}", get_error())
800+
Err(get_error())
801+
} else {
802+
Ok(())
800803
}
801804
}
802805

0 commit comments

Comments
 (0)