Add debug impls (#56)

* Add missing `Debug` impls to public types

In one case, a missing Clone and Copy impl was added, too.

* Remove several `doc(hidden)` & make some modules private

I'm not quite sure why it was done the way it was. This change makes
items that were used in the public API visible in the documentation. It
also makes modules not used in the public API private.

* Add `#![deny(missing_debug_implementations)]` to crate root
This commit is contained in:
Lukas Kalbertodt 2018-08-10 09:14:14 +02:00 committed by Daniel Collin
parent 9b835f9331
commit 87e742047d

View file

@ -2,12 +2,15 @@
//! open windows (usually native to the running operating system) and can optionally show a 32-bit //! open windows (usually native to the running operating system) and can optionally show a 32-bit
//! buffer. minifb also support keyboard, mouse input and menus on selected operating systems. //! buffer. minifb also support keyboard, mouse input and menus on selected operating systems.
//! //!
#![deny(missing_debug_implementations)]
use std::fmt;
use std::os::raw; use std::os::raw;
/// Scale will scale the frame buffer and the window that is being sent in when calling the update /// Scale will scale the frame buffer and the window that is being sent in when calling the update
/// function. This is useful if you for example want to display a 320 x 256 window on a screen with /// function. This is useful if you for example want to display a 320 x 256 window on a screen with
/// much higher resolution which would result in that the window is very small. /// much higher resolution which would result in that the window is very small.
#[derive(Clone, Copy)] #[derive(Clone, Copy, Debug)]
pub enum Scale { pub enum Scale {
/// This mode checks your current screen resolution and will caluclate the largest window size /// This mode checks your current screen resolution and will caluclate the largest window size
/// that can be used within that limit and resize it. Useful if you have a small buffer to /// that can be used within that limit and resize it. Useful if you have a small buffer to
@ -28,7 +31,7 @@ pub enum Scale {
} }
/// Used for is_key_pressed and get_keys_pressed() to indicated if repeat of presses is wanted /// Used for is_key_pressed and get_keys_pressed() to indicated if repeat of presses is wanted
#[derive(PartialEq, Clone, Copy)] #[derive(PartialEq, Clone, Copy, Debug)]
pub enum KeyRepeat { pub enum KeyRepeat {
/// Use repeat /// Use repeat
Yes, Yes,
@ -37,9 +40,8 @@ pub enum KeyRepeat {
} }
/// The various mouse buttons that are availible /// The various mouse buttons that are availible
#[derive(PartialEq, Clone, Copy)] #[derive(PartialEq, Clone, Copy, Debug)]
pub enum MouseButton pub enum MouseButton {
{
/// Left mouse button /// Left mouse button
Left, Left,
/// Middle mouse button /// Middle mouse button
@ -50,7 +52,7 @@ pub enum MouseButton
/// The diffrent modes that can be used to decide how mouse coordinates should be handled /// The diffrent modes that can be used to decide how mouse coordinates should be handled
#[derive(PartialEq, Clone, Copy)] #[derive(PartialEq, Clone, Copy, Debug)]
pub enum MouseMode { pub enum MouseMode {
/// Return mouse coords from outside of the window (may be negative) /// Return mouse coords from outside of the window (may be negative)
Pass, Pass,
@ -61,7 +63,7 @@ pub enum MouseMode {
} }
/// Different style of cursors that can be used /// Different style of cursors that can be used
#[derive(PartialEq, Clone, Copy)] #[derive(PartialEq, Clone, Copy, Debug)]
pub enum CursorStyle { pub enum CursorStyle {
/// Regular arrow style (this is what the cursor normal looks like) /// Regular arrow style (this is what the cursor normal looks like)
Arrow, Arrow,
@ -87,18 +89,13 @@ pub trait InputCallback {
fn add_char(&mut self, uni_char: u32); fn add_char(&mut self, uni_char: u32);
} }
#[doc(hidden)]
mod error; mod error;
pub use self::error::Error; pub use self::error::Error;
#[doc(hidden)]
pub type Result<T> = std::result::Result<T, Error>; pub type Result<T> = std::result::Result<T, Error>;
#[doc(hidden)] mod key;
pub mod key;
#[doc(hidden)]
pub use key::Key as Key; pub use key::Key as Key;
#[doc(hidden)] mod os;
pub mod os;
mod mouse_handler; mod mouse_handler;
mod buffer_helper; mod buffer_helper;
mod key_handler; mod key_handler;
@ -130,10 +127,19 @@ use self::os::redox as imp;
/// ///
pub struct Window(imp::Window); pub struct Window(imp::Window);
impl fmt::Debug for Window {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("Window")
.field(&format_args!(".."))
.finish()
}
}
/// ///
/// WindowOptions is creation settings for the window. By default the settings are defined for /// WindowOptions is creation settings for the window. By default the settings are defined for
/// displayng a 32-bit buffer (no scaling of window is possible) /// displayng a 32-bit buffer (no scaling of window is possible)
/// ///
#[derive(Clone, Copy, Debug)]
pub struct WindowOptions { pub struct WindowOptions {
/// If the window should be borderless (default: false) /// If the window should be borderless (default: false)
pub borderless: bool, pub borderless: bool,
@ -142,7 +148,7 @@ pub struct WindowOptions {
/// If it should be possible to resize the window (default: false) /// If it should be possible to resize the window (default: false)
pub resize: bool, pub resize: bool,
/// Scale of the window that used in conjunction with update_with_buffer (default: X1) /// Scale of the window that used in conjunction with update_with_buffer (default: X1)
pub scale: Scale pub scale: Scale,
} }
impl Window { impl Window {
@ -625,6 +631,14 @@ pub struct MenuHandle(pub u64);
/// ///
pub struct Menu(imp::Menu); pub struct Menu(imp::Menu);
impl fmt::Debug for Menu {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("Menu")
.field(&format_args!(".."))
.finish()
}
}
impl Menu { impl Menu {
/// Create a new menu. Returns error if failed /// Create a new menu. Returns error if failed
pub fn new(name: &str) -> Result<Menu> { pub fn new(name: &str) -> Result<Menu> {
@ -680,6 +694,7 @@ impl Menu {
/// ///
/// Holds info about each item in a menu /// Holds info about each item in a menu
/// ///
#[derive(Debug)]
pub struct MenuItem<'a> { pub struct MenuItem<'a> {
pub id: usize, pub id: usize,
pub label: String, pub label: String,
@ -789,7 +804,6 @@ impl<'a> MenuItem<'a> {
// Impl for WindowOptions // Impl for WindowOptions
#[doc(hidden)]
impl Default for WindowOptions { impl Default for WindowOptions {
fn default() -> WindowOptions { fn default() -> WindowOptions {
WindowOptions { WindowOptions {
@ -800,5 +814,3 @@ impl Default for WindowOptions {
} }
} }
} }