Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug traits for structs #20

Merged
merged 2 commits into from
Sep 1, 2017
Merged

Conversation

shivanth
Copy link
Contributor

Fixes #14

Copy link
Collaborator

@KodrAus KodrAus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @shivanth!

@@ -459,6 +460,19 @@ impl Log for Logger {
fn flush(&self) {}
}

impl fmt::Debug for Logger{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some nice helper methods on Formatter that can make this easier. So you could have something like:

f.debug_struct("Logger")
 .field("directives", &self.directives)
 .field("filter", &self.filter)
 .field("target", &self.target)
 .finish()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :-)

@@ -4,6 +4,7 @@ use std::fmt;

use self::regex::Regex;

#[derive(Debug)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want the debug representation to display the values of these private internal fields? Right now this will output the debug value of the inner: Regex field. We may well want that, but I think it's worth making that decision explicit. Are you ok with this @sebasmagri?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any comments on this ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is ok. Let's merge this in.

@KodrAus KodrAus merged commit c01ccca into rust-cli:master Sep 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants