From c24619861eb88a1cdf72c62bed7dc87c1c558038 Mon Sep 17 00:00:00 2001 From: Victor Brekenfeld Date: Sat, 8 Dec 2018 13:46:55 +0100 Subject: [PATCH] egl: style: move constraints into where clause --- src/backend/drm/egl/mod.rs | 50 +++++++++++++++------------------- src/backend/drm/egl/session.rs | 9 +++--- src/backend/drm/egl/surface.rs | 19 +++++++------ 3 files changed, 37 insertions(+), 41 deletions(-) diff --git a/src/backend/drm/egl/mod.rs b/src/backend/drm/egl/mod.rs index c834875..b918427 100644 --- a/src/backend/drm/egl/mod.rs +++ b/src/backend/drm/egl/mod.rs @@ -32,21 +32,20 @@ pub use self::surface::*; pub mod session; /// Representation of an egl device to create egl rendering surfaces -pub struct EglDevice< +pub struct EglDevice +where B: Backend::Surface> + 'static, D: Device + NativeDisplay + 'static, -> where ::Surface: NativeSurface, { dev: Rc>, logger: ::slog::Logger, } -impl< - B: Backend::Surface> + 'static, - D: Device + NativeDisplay + 'static, - > AsRawFd for EglDevice +impl AsRawFd for EglDevice where + B: Backend::Surface> + 'static, + D: Device + NativeDisplay + 'static, ::Surface: NativeSurface, { fn as_raw_fd(&self) -> RawFd { @@ -54,11 +53,10 @@ where } } -impl< - B: Backend::Surface> + 'static, - D: Device + NativeDisplay + 'static, - > EglDevice +impl EglDevice where + B: Backend::Surface> + 'static, + D: Device + NativeDisplay + 'static, ::Surface: NativeSurface, { /// Try to create a new `EglDevice` from an open device. @@ -104,20 +102,19 @@ where } } -struct InternalDeviceHandler< +struct InternalDeviceHandler +where B: Backend::Surface> + 'static, D: Device + NativeDisplay + 'static, -> where ::Surface: NativeSurface, { handler: Box> + 'static>, } -impl< - B: Backend::Surface> + 'static, - D: Device + NativeDisplay + 'static, - > DeviceHandler for InternalDeviceHandler +impl DeviceHandler for InternalDeviceHandler where + B: Backend::Surface> + 'static, + D: Device + NativeDisplay + 'static, ::Surface: NativeSurface, { type Device = D; @@ -131,11 +128,10 @@ where } } -impl< - B: Backend::Surface> + 'static, - D: Device + NativeDisplay + 'static, - > Device for EglDevice +impl Device for EglDevice where + B: Backend::Surface> + 'static, + D: Device + NativeDisplay + 'static, ::Surface: NativeSurface, { type Surface = EglSurface; @@ -185,11 +181,10 @@ where } #[cfg(feature = "native_lib")] -impl< - B: Backend::Surface> + 'static, - D: Device + NativeDisplay + 'static, - > EGLGraphicsBackend for EglDevice +impl EGLGraphicsBackend for EglDevice where + B: Backend::Surface> + 'static, + D: Device + NativeDisplay + 'static, ::Surface: NativeSurface, { fn bind_wl_display(&self, display: &Display) -> EGLResult { @@ -197,11 +192,10 @@ where } } -impl< - B: Backend::Surface> + 'static, - D: Device + NativeDisplay + 'static, - > Drop for EglDevice +impl Drop for EglDevice where + B: Backend::Surface> + 'static, + D: Device + NativeDisplay + 'static, ::Surface: NativeSurface, { fn drop(&mut self) { diff --git a/src/backend/drm/egl/session.rs b/src/backend/drm/egl/session.rs index b07d8a9..0d6fc3f 100644 --- a/src/backend/drm/egl/session.rs +++ b/src/backend/drm/egl/session.rs @@ -18,12 +18,11 @@ pub struct EglDeviceObserver { observer: S, } -impl< - S: SessionObserver + 'static, - B: Backend::Surface> + 'static, - D: Device + NativeDisplay + AsSessionObserver + 'static, - > AsSessionObserver> for EglDevice +impl AsSessionObserver> for EglDevice where + S: SessionObserver + 'static, + B: Backend::Surface> + 'static, + D: Device + NativeDisplay + AsSessionObserver + 'static, ::Surface: NativeSurface, { fn observer(&mut self) -> EglDeviceObserver { diff --git a/src/backend/drm/egl/surface.rs b/src/backend/drm/egl/surface.rs index 0c17a9b..064825e 100644 --- a/src/backend/drm/egl/surface.rs +++ b/src/backend/drm/egl/surface.rs @@ -13,19 +13,20 @@ use backend::graphics::PixelFormat; use backend::graphics::{CursorBackend, SwapBuffersError}; /// Egl surface for rendering -pub struct EglSurface< +pub struct EglSurface +where B: Backend::Surface> + 'static, D: Device + NativeDisplay + 'static, -> where ::Surface: NativeSurface, { pub(super) dev: Rc>, pub(super) surface: EGLSurface, } -impl::Surface> + 'static, D: Device + NativeDisplay + 'static> Surface - for EglSurface +impl Surface for EglSurface where + B: Backend::Surface> + 'static, + D: Device + NativeDisplay + 'static, ::Surface: NativeSurface, { type Error = Error; @@ -70,9 +71,10 @@ where } } -impl<'a, B: Backend::Surface> + 'static, D: Device + NativeDisplay + 'static> - CursorBackend<'a> for EglSurface +impl<'a, B, D> CursorBackend<'a> for EglSurface where + B: Backend::Surface> + 'static, + D: Device + NativeDisplay + 'static, ::Surface: NativeSurface + CursorBackend<'a>, { type CursorFormat = >::CursorFormat; @@ -95,9 +97,10 @@ where } #[cfg(feature = "renderer_gl")] -impl::Surface> + 'static, D: Device + NativeDisplay + 'static> - GLGraphicsBackend for EglSurface +impl GLGraphicsBackend for EglSurface where + B: Backend::Surface> + 'static, + D: Device + NativeDisplay + 'static, ::Surface: NativeSurface, { fn swap_buffers(&self) -> ::std::result::Result<(), SwapBuffersError> {