[Debug Trait] Remove unnecessary manual imps

This commit is contained in:
Poly 2021-02-23 20:21:20 +01:00
parent 804a6cb59f
commit d2373fdddd
2 changed files with 3 additions and 52 deletions

View File

@ -43,6 +43,7 @@ use wayland_server::Display;
/// [`Device`](::backend::drm::Device) Wrapper to assist fallback /// [`Device`](::backend::drm::Device) Wrapper to assist fallback
/// in case initialization of the preferred device type fails. /// in case initialization of the preferred device type fails.
#[derive(Debug)]
pub enum FallbackDevice<D1: Device + 'static, D2: Device + 'static> { pub enum FallbackDevice<D1: Device + 'static, D2: Device + 'static> {
/// Variant for successful initialization of the preferred device /// Variant for successful initialization of the preferred device
Preference(D1), Preference(D1),
@ -50,22 +51,6 @@ pub enum FallbackDevice<D1: Device + 'static, D2: Device + 'static> {
Fallback(D2), Fallback(D2),
} }
// Device is a trait, so we have to impl Debug manually
impl<D1: Device + 'static, D2: Device + 'static> fmt::Debug for FallbackDevice<D1, D2> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
FallbackDevice::Preference(d) => f
.debug_struct("FallbackDevice::Preference")
.field("device_id", &d.device_id())
.finish(),
FallbackDevice::Fallback(d) => f
.debug_struct("FallbackDevice::Preference")
.field("device_id", &d.device_id())
.finish(),
}
}
}
struct FallbackDeviceHandlerD1<E1, E2, C, S1, S2, D1, D2>( struct FallbackDeviceHandlerD1<E1, E2, C, S1, S2, D1, D2>(
Box<dyn DeviceHandler<Device = FallbackDevice<D1, D2>> + 'static>, Box<dyn DeviceHandler<Device = FallbackDevice<D1, D2>> + 'static>,
) )
@ -146,6 +131,7 @@ where
/// [`Surface`](::backend::drm::Surface) Wrapper to assist fallback /// [`Surface`](::backend::drm::Surface) Wrapper to assist fallback
/// in case initialization of the preferred device type fails. /// in case initialization of the preferred device type fails.
#[derive(Debug)]
pub enum FallbackSurface<S1: Surface, S2: Surface> { pub enum FallbackSurface<S1: Surface, S2: Surface> {
/// Variant for successful initialization of the preferred device /// Variant for successful initialization of the preferred device
Preference(S1), Preference(S1),
@ -153,22 +139,6 @@ pub enum FallbackSurface<S1: Surface, S2: Surface> {
Fallback(S2), Fallback(S2),
} }
// Surface is a trait, so we have to impl Debug manually
impl<S1: Surface, S2: Surface> fmt::Debug for FallbackSurface<S1, S2> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
FallbackSurface::Preference(s) => f
.debug_struct("FallbackDevice::Preference")
.field("crtc", &s.crtc())
.finish(),
FallbackSurface::Fallback(s) => f
.debug_struct("FallbackDevice::Preference")
.field("crtc", &s.crtc())
.finish(),
}
}
}
/// Enum uniting two kinds of possible errors. /// Enum uniting two kinds of possible errors.
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
pub enum EitherError<E1: std::error::Error + 'static, E2: std::error::Error + 'static> { pub enum EitherError<E1: std::error::Error + 'static, E2: std::error::Error + 'static> {

View File

@ -425,28 +425,9 @@ impl From<event::pointer::ButtonState> for backend::MouseButtonState {
/// Wrapper for types implementing the [`Session`] trait to provide /// Wrapper for types implementing the [`Session`] trait to provide
/// a [`libinput::LibinputInterface`] implementation. /// a [`libinput::LibinputInterface`] implementation.
#[cfg(feature = "backend_session")] #[cfg(feature = "backend_session")]
#[derive(Debug)]
pub struct LibinputSessionInterface<S: Session>(S); pub struct LibinputSessionInterface<S: Session>(S);
// Session is a trait, so we have to impl Debug manually
#[cfg(feature = "backend_session")]
impl<S: Session> fmt::Debug for LibinputSessionInterface<S> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
struct SessionDebug<'a, S: Session>(&'a S);
impl<'a, S: Session> fmt::Debug for SessionDebug<'a, S> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Session")
.field("is_active", &self.0.is_active())
.field("seat", &self.0.seat())
.finish()
}
}
f.debug_tuple("LibinputSessionInterface")
.field(&SessionDebug(&self.0))
.finish()
}
}
#[cfg(feature = "backend_session")] #[cfg(feature = "backend_session")]
impl<S: Session> From<S> for LibinputSessionInterface<S> { impl<S: Session> From<S> for LibinputSessionInterface<S> {
fn from(session: S) -> LibinputSessionInterface<S> { fn from(session: S) -> LibinputSessionInterface<S> {