Skip to content

Commit cfbde60

Browse files
committed
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.
1 parent 08883d7 commit cfbde60

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,13 @@ impl<W: HasRawWindowHandle> GraphicsContext<W> {
109109
}
110110
}
111111

112+
impl<W: HasRawWindowHandle> AsRef<W> for GraphicsContext<W> {
113+
/// Equivalent to [`self.window()`](Self::window()).
114+
fn as_ref(&self) -> &W {
115+
self.window()
116+
}
117+
}
118+
112119
trait GraphicsContextImpl {
113120
unsafe fn set_buffer(&mut self, buffer: &[u32], width: u16, height: u16);
114121
}

0 commit comments

Comments
 (0)