Currently, the code in the lesson looks like this:
// ~/src/phi/data.rs
// ...
pub fn to_sdl(self) -> Option<SdlRect> {
assert!(self.w >= 0.0 && self.h >= 0.0);
SdlRect::new(
self.x as i32, self.y as i32, self.w as u32, self.h as u32
)
}
With newer version of sdl2(v0.24.0 specifically) this will fail at the compile step as Renderer.copy() expects 2 Option<Rect>'s as arguments. I'm fairly new to Rust, but I fixed the issue by changing the code to the following:
pub fn to_sdl(self) -> Option<SdlRect> {
assert!(self.w >= 0.0 && self.h >= 0.0);
Some(SdlRect::new(
self.x as i32, self.y as i32, self.w as u32, self.h as u32
))
}
Let me know if you think this a good solution.