Accept FnOnce instead of Fn in canvas cache draw

Use FnOnce in `draw` function signature instead of `Fn`, permitting the
use of iterators and other one-time functions.
This commit is contained in:
sushigiri 2023-02-06 09:05:07 -07:00
parent 98a717383a
commit c7d8467c46
No known key found for this signature in database
GPG key ID: CD1F92B7DBB25E88

View file

@ -49,7 +49,11 @@ impl Cache {
/// Otherwise, the previously stored [`Geometry`] will be returned. The
/// [`Cache`] is not cleared in this case. In other words, it will keep
/// returning the stored [`Geometry`] if needed.
pub fn draw(&self, bounds: Size, draw_fn: impl Fn(&mut Frame)) -> Geometry {
pub fn draw(
&self,
bounds: Size,
draw_fn: impl FnOnce(&mut Frame),
) -> Geometry {
use std::ops::Deref;
if let State::Filled {