From cfbde6073c2bb5219448685ce1065ed5379ae863 Mon Sep 17 00:00:00 2001 From: Kevin Reid Date: Thu, 26 May 2022 08:37:11 -0700 Subject: [PATCH] Add `impl AsRef for GraphicsContext`. 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. --- src/lib.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index d179924..081f7a0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -109,6 +109,13 @@ impl GraphicsContext { } } +impl AsRef for GraphicsContext { + /// 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); }