Skip to content

Add Debug derive to std::process::Output #30403

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

Merged
merged 1 commit into from
Dec 19, 2015
Merged

Add Debug derive to std::process::Output #30403

merged 1 commit into from
Dec 19, 2015

Conversation

webmobster-zz
Copy link
Contributor

I didn't see any reason that debug couldn't be added to this object, since every field derives debug.

@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@sfackler
Copy link
Member

Actually, I'm not sure the derived impl would be best here. Stdout and stderr are both Vec<u8>, so their output will be e.g. [32, 20, 39, 20, ...] which is not going to be great to look at.

@webmobster-zz
Copy link
Contributor Author

What would be the alternative assume the stdout/stder will always be utf8 or ascii and convert the outputs to a utf8 string?

@sfackler
Copy link
Member

String::from_utf8_lossy is one option. It could maybe also see if it's UTF8 and if not fall back to the raw output, possibly truncated?

@brson
Copy link
Contributor

brson commented Dec 15, 2015

Since stdout/err doesn't need to be text I prefer @sfackler's latter option, printing text if utf8 and binary if not. Truncated in each case I guess.

@webmobster-zz
Copy link
Contributor Author

If thats the consensus I can write up a debug implementation tomorrow (late here). I'll keep the pull request open till thats done I guess.

@sfackler
Copy link
Member

Sounds good!

@webmobster-zz
Copy link
Contributor Author

What should I put as the stability annotation on the function?

@sfackler
Copy link
Member

The stability checking logic doesn't check trait implementations, so it's automatically stable.

@webmobster-zz
Copy link
Contributor Author

I got a "src/libstd/process.rs:406:1: 429:2 error: This node does not have a stability attribute", on a build I ran myself

@petrochenkov
Copy link
Contributor

@webmobster
#[stable(feature = "process_output_debug", since = "1.7.0")]
Even though these annotations are not checked now, they are still required for documentation and possible future checking.

@@ -400,6 +401,33 @@ pub struct Output {
pub stderr: Vec<u8>,
}

//If either stderr or stdout are valid utf8 strings it prints the valid strings, otherwise it
//prints the byte sequence instead
Copy link
Member

Choose a reason for hiding this comment

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

Stylistically there's typically a space after the //, and can you also format this comment to a maximum width of 80 chars? (the surrounding style)

@alexcrichton
Copy link
Member

Looks good to me (including the stability annotation @petrochenkov mentioned)

@webmobster-zz
Copy link
Contributor Author

Done

@alexcrichton
Copy link
Member

@bors: r+ 21030f1

Thanks!

@bors
Copy link
Collaborator

bors commented Dec 19, 2015

⌛ Testing commit 21030f1 with merge 67a2d1f...

bors added a commit that referenced this pull request Dec 19, 2015
I didn't see any reason that debug couldn't be added to this object, since every field derives debug.
@bors bors merged commit 21030f1 into rust-lang:master Dec 19, 2015
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.

8 participants