Skip to content

Commit 95dc181

Browse files
committed
Make From generic
2 parents 804b848 + 657a3a8 commit 95dc181

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
name = "piston_window"
4-
version = "0.1.0"
4+
version = "0.2.0"
55
authors = ["bvssvni <[email protected]>"]
66
keywords = ["window", "piston"]
77
description = "The official Piston window back-end for the Piston game engine"

src/lib.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ type Glyphs = gfx_graphics::GlyphCache<gfx_device_gl::Resources, gfx_device_gl::
3232
/// 2D graphics.
3333
type G2d<'a> = GfxGraphics<'a, gfx_device_gl::Resources, gfx_device_gl::CommandBuffer, gfx_device_gl::Output>;
3434

35-
/// Creates a window using default window back-end.
36-
pub fn window(settings: WindowSettings) -> Rc<RefCell<GlutinWindow>> {
37-
Rc::new(RefCell::new(GlutinWindow::new(settings)))
38-
}
39-
4035
/// Contains everything required for controlling window, graphics, event loop.
4136
pub struct PistonWindow<W: window::Window = GlutinWindow, T = ()> {
4237
/// The window.
@@ -57,9 +52,12 @@ pub struct PistonWindow<W: window::Window = GlutinWindow, T = ()> {
5752
pub factory: Rc<RefCell<gfx_device_gl::Factory>>,
5853
}
5954

60-
impl From<WindowSettings> for PistonWindow {
61-
fn from(settings: WindowSettings) -> PistonWindow {
62-
PistonWindow::new(window(settings), empty_app())
55+
impl<T> From<WindowSettings> for PistonWindow<T>
56+
where T: Window + OpenGLWindow + From<WindowSettings>,
57+
T::Event: GenericEvent
58+
{
59+
fn from(settings: WindowSettings) -> PistonWindow<T> {
60+
PistonWindow::new(Rc::new(RefCell::new(settings.into())), empty_app())
6361
}
6462
}
6563

0 commit comments

Comments
 (0)