Skip to content

Commit

Permalink
Renderer.fill_rect now takes an Into<Option<Rect>>.
Browse files Browse the repository at this point in the history
This should allow passing Rect, Some(Rect) or None to fill_rect.
Passing None to fill_rect fills the entire rendering target.
  • Loading branch information
Zoomulator authored and Cobrand committed Nov 27, 2016
1 parent b64d7a6 commit 53c8a40
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/sdl2/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,10 +739,11 @@ impl<'a> Renderer<'a> {

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

0 comments on commit 53c8a40

Please sign in to comment.