summaryrefslogblamecommitdiffstats
path: root/wgpu/src/widget/canvas/drawable.rs
blob: 48ba6b4c1f304c6f238c543dbd2bef618860fa6d (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12











                                                      





                                               
use crate::canvas::Frame;

/// A type that can be drawn on a [`Frame`].
///
/// [`Frame`]: struct.Frame.html
pub trait Drawable {
    /// Draws the [`Drawable`] on the given [`Frame`].
    ///
    /// [`Drawable`]: trait.Drawable.html
    /// [`Frame`]: struct.Frame.html
    fn draw(&self, frame: &mut Frame);
}

impl<'a> Drawable for dyn Fn(&mut Frame) + 'a {
    fn draw(&self, frame: &mut Frame) {
        self(frame)
    }
}