Skip to content

Commit

Permalink
Make publicly exported types implement Debug trait
Browse files Browse the repository at this point in the history
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 rust-lang/rust#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.
  • Loading branch information
d-e-s-o committed Feb 10, 2019
1 parent ba89e7e commit 15c97fc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![deny(missing_debug_implementations)]

extern crate byteorder;
extern crate num_traits;

Expand All @@ -13,4 +15,4 @@ pub mod proto;
pub mod agent;
pub mod error;

pub use self::agent::Agent;
pub use self::agent::Agent;
3 changes: 2 additions & 1 deletion src/proto/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use serde::de::{

use super::error::{ProtoError, ProtoResult};

#[derive(Debug)]
pub struct Deserializer<R: io::Read> {
reader: R,
}
Expand Down Expand Up @@ -251,4 +252,4 @@ impl<'de, 'a, R: io::Read> VariantAccess<'de> for BinaryEnum<'a, R> {
) -> ProtoResult<V::Value> {
de::Deserializer::deserialize_map(self.de, visitor)
}
}
}
1 change: 1 addition & 0 deletions src/proto/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use serde::ser::{self, Serialize};
use std::io;
use super::error::{ProtoError, ProtoResult};

#[derive(Debug)]
pub struct Serializer<W: io::Write> {
// This string starts empty and JSON is appended as values are serialized.
writer: W
Expand Down

0 comments on commit 15c97fc

Please sign in to comment.