Skip to content

Commit 53c8a40

Browse files
ZoomulatorCobrand
authored andcommitted
Renderer.fill_rect now takes an Into<Option<Rect>>.
This should allow passing Rect, Some(Rect) or None to fill_rect. Passing None to fill_rect fills the entire rendering target.
1 parent b64d7a6 commit 53c8a40

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/sdl2/render.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -739,10 +739,11 @@ impl<'a> Renderer<'a> {
739739

740740
/// Fills a rectangle on the current rendering target with the drawing
741741
/// color.
742+
/// Passing None will fill the entire rendering target.
742743
/// Errors if drawing fails for any reason (e.g. driver failure)
743-
pub fn fill_rect(&mut self, rect: Rect) -> Result<(), String> {
744+
pub fn fill_rect<R: Into<Option<Rect>>>(&mut self, rect: R) -> Result<(), String> {
744745
let result = unsafe {
745-
ll::SDL_RenderFillRect(self.raw, rect.raw())
746+
ll::SDL_RenderFillRect(self.raw, rect.into().map(|r|{r.raw()}).unwrap_or(ptr::null()))
746747
};
747748
if result != 0 {
748749
Err(get_error())

0 commit comments

Comments
 (0)