Closed StefanoIncardone closed 10 months ago
I guess that would be fine, but I would prefer keeping the old one around for a while with a deprecation tag then.
I guess that would be fine, but I would prefer keeping the old one around for a while with a deprecation tag then.
That was exactly what i was thinking, so i'm up for any suggestions on how you'd like to handle deprecations
I guess having something like
#[deprecated(since = "0.26", note = "use set_fps_target instead, this function will be removed in the future."]
on the old function. Also given no time when it will be removed gives some flexibility
I guess having something like
#[deprecated(since = "0.26", note = "use set_fps_target instead, this function will be removed in the future."]
on the old function. Also given no time when it will be removed gives some flexibility
I would also like to ask how to handle the possibility of setting the FPS to 0 (would crash when calculating 1 / fps), as i came up with different solutions:
pub fn set_target_fps(&mut self, fps: Option<NonZeroUsize>) {
match fps {
Some(fps) => {
let fps: usize = fps.into();
self.0
.set_rate(Some(Duration::from_secs_f32(1. / fps as f32)));
}
None => self.0.set_rate(None),
}
}
pub fn set_target_fps(&mut self, fps: Option<usize>) -> std::result::Result<(), ZeroFPS> {
match fps {
Some(fps) => match fps {
0 => return Err(ZeroFPS),
non_zero => self.0.set_rate(Some(Duration::from_secs_f32(1. / non_zero as f32))),
},
None => self.0.set_rate(None),
}
Ok(())
}
pub fn set_target_fps(&mut self, fps: usize) {
match fps {
0 => self.0.set_rate(None),
non_zero => self.0.set_rate(Some(Duration::from_secs_f32(1. / non_zero as f32))),
}
}
I think 3.
I think 3.
Thanks, I'll make a PR with that then
possibily replace limit_update_rate with this implementation of "set_target_fps", since FPS is a more common and natural way to represent update intervals: