Implement Debug trait on exported opaque types (#677)

* Implement `Debug` trait on exported opaque types

* Make formatting consistent
This commit is contained in:
George Burton 2018-10-18 04:20:12 +01:00 committed by Francesca Plebani
parent 7baa96c5c7
commit f486845f7f
2 changed files with 28 additions and 1 deletions

View file

@ -13,8 +13,9 @@
- Fixed UTF8 handling bug in X11 `set_title` function. - 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, `Window::set_cursor` now applies immediately instead of requiring specific events to occur first.
- On Windows, fix `Window::set_maximized`. - On Windows, fix `Window::set_maximized`.
- On Windows, fix transparency (#260). - On Windows 10, fix transparency (#260).
- on macOS, fix modifiers during key repeat. - on macOS, fix modifiers during key repeat.
- Implemented the `Debug` trait for `Window`, `EventsLoop`, `EventsLoopProxy` and `WindowBuilder`.
# Version 0.17.2 (2018-08-19) # Version 0.17.2 (2018-08-19)

View file

@ -149,6 +149,12 @@ pub struct Window {
window: platform::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. /// Identifier of a window. Unique for each window.
/// ///
/// Can be obtained with `window.id()`. /// Can be obtained with `window.id()`.
@ -184,6 +190,12 @@ pub struct EventsLoop {
_marker: ::std::marker::PhantomData<*mut ()> // Not Send nor Sync _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. /// Returned by the user callback given to the `EventsLoop::run_forever` method.
/// ///
/// Indicates whether the `run_forever` method should continue or complete. /// Indicates whether the `run_forever` method should continue or complete.
@ -263,6 +275,12 @@ pub struct EventsLoopProxy {
events_loop_proxy: platform::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 { impl EventsLoopProxy {
/// Wake up the `EventsLoop` from which this proxy was created. /// Wake up the `EventsLoop` from which this proxy was created.
/// ///
@ -301,6 +319,14 @@ pub struct WindowBuilder {
platform_specific: platform::PlatformSpecificWindowBuilderAttributes, 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. /// Error that can happen while creating a window or a headless renderer.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum CreationError { pub enum CreationError {