Add impl AsRef<W> for GraphicsContext<W>.

This will allow code which works with windows generically (such as an
event loop which can work with `softbuffer` or another graphics library)
to be able to access the underlying window without knowing about
`softbuffer` in particular.
This commit is contained in:
Kevin Reid 2022-05-26 08:37:11 -07:00
parent 08883d76c5
commit cfbde6073c

View file

@ -109,6 +109,13 @@ impl<W: HasRawWindowHandle> GraphicsContext<W> {
}
}
impl<W: HasRawWindowHandle> AsRef<W> for GraphicsContext<W> {
/// Equivalent to [`self.window()`](Self::window()).
fn as_ref(&self) -> &W {
self.window()
}
}
trait GraphicsContextImpl {
unsafe fn set_buffer(&mut self, buffer: &[u32], width: u16, height: u16);
}