From 15c97fc11e57619abac9e73826faafc31fe0a5ab Mon Sep 17 00:00:00 2001 From: Daniel Mueller Date: Sat, 9 Feb 2019 21:28:00 -0800 Subject: [PATCH] Make publicly exported types implement Debug trait It seems to have become common practice for publicly exported types in a library to implement the Debug trait. Doing so potentially simplifies trouble shooting in client code directly but it also is a requirement in case said client code embeds such objects and wants the wrappers to implement this trait. For a deeper discussion of this topic please refer to https://github.com/rust-lang/rust/pull/32054 To that end, this change adjust all publicly exported types to derive from Debug. It also adds a crate wide lint enforcing this constraint. --- src/lib.rs | 4 +++- src/proto/de.rs | 3 ++- src/proto/ser.rs | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 02a8461..c5da8ce 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,5 @@ +#![deny(missing_debug_implementations)] + extern crate byteorder; extern crate num_traits; @@ -13,4 +15,4 @@ pub mod proto; pub mod agent; pub mod error; -pub use self::agent::Agent; \ No newline at end of file +pub use self::agent::Agent; diff --git a/src/proto/de.rs b/src/proto/de.rs index bc67df7..b0c0c79 100644 --- a/src/proto/de.rs +++ b/src/proto/de.rs @@ -8,6 +8,7 @@ use serde::de::{ use super::error::{ProtoError, ProtoResult}; +#[derive(Debug)] pub struct Deserializer { reader: R, } @@ -251,4 +252,4 @@ impl<'de, 'a, R: io::Read> VariantAccess<'de> for BinaryEnum<'a, R> { ) -> ProtoResult { de::Deserializer::deserialize_map(self.de, visitor) } -} \ No newline at end of file +} diff --git a/src/proto/ser.rs b/src/proto/ser.rs index f52ca68..5004378 100644 --- a/src/proto/ser.rs +++ b/src/proto/ser.rs @@ -3,6 +3,7 @@ use serde::ser::{self, Serialize}; use std::io; use super::error::{ProtoError, ProtoResult}; +#[derive(Debug)] pub struct Serializer { // This string starts empty and JSON is appended as values are serialized. writer: W