From f486845f7f20b9ff1c76d7f78e26415e301ff8d9 Mon Sep 17 00:00:00 2001 From: George Burton Date: Thu, 18 Oct 2018 04:20:12 +0100 Subject: [PATCH] Implement `Debug` trait on exported opaque types (#677) * Implement `Debug` trait on exported opaque types * Make formatting consistent --- CHANGELOG.md | 3 ++- src/lib.rs | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fa5a248..fde3d44b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,8 +13,9 @@ - Fixed UTF8 handling bug in X11 `set_title` function. - On Windows, `Window::set_cursor` now applies immediately instead of requiring specific events to occur first. - On Windows, fix `Window::set_maximized`. -- On Windows, fix transparency (#260). +- On Windows 10, fix transparency (#260). - on macOS, fix modifiers during key repeat. +- Implemented the `Debug` trait for `Window`, `EventsLoop`, `EventsLoopProxy` and `WindowBuilder`. # Version 0.17.2 (2018-08-19) diff --git a/src/lib.rs b/src/lib.rs index c7592a6a..2bfecfb7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -149,6 +149,12 @@ pub struct Window { window: platform::Window, } +impl std::fmt::Debug for Window { + fn fmt(&self, fmtr: &mut std::fmt::Formatter) -> std::fmt::Result { + fmtr.pad("Window { .. }") + } +} + /// Identifier of a window. Unique for each window. /// /// Can be obtained with `window.id()`. @@ -184,6 +190,12 @@ pub struct EventsLoop { _marker: ::std::marker::PhantomData<*mut ()> // Not Send nor Sync } +impl std::fmt::Debug for EventsLoop { + fn fmt(&self, fmtr: &mut std::fmt::Formatter) -> std::fmt::Result { + fmtr.pad("EventsLoop { .. }") + } +} + /// Returned by the user callback given to the `EventsLoop::run_forever` method. /// /// Indicates whether the `run_forever` method should continue or complete. @@ -263,6 +275,12 @@ pub struct EventsLoopProxy { events_loop_proxy: platform::EventsLoopProxy, } +impl std::fmt::Debug for EventsLoopProxy { + fn fmt(&self, fmtr: &mut std::fmt::Formatter) -> std::fmt::Result { + fmtr.pad("EventsLoopProxy { .. }") + } +} + impl EventsLoopProxy { /// Wake up the `EventsLoop` from which this proxy was created. /// @@ -301,6 +319,14 @@ pub struct WindowBuilder { platform_specific: platform::PlatformSpecificWindowBuilderAttributes, } +impl std::fmt::Debug for WindowBuilder { + fn fmt(&self, fmtr: &mut std::fmt::Formatter) -> std::fmt::Result { + fmtr.debug_struct("WindowBuilder") + .field("window", &self.window) + .finish() + } +} + /// Error that can happen while creating a window or a headless renderer. #[derive(Debug, Clone)] pub enum CreationError {