OutputContext: Add new, into_output_and_command, and output_error#28
Merged
OutputContext: Add new, into_output_and_command, and output_error#28
new, into_output_and_command, and output_error#28Conversation
I learned it's actually impossible (!) for consumers to implement `CommandExt` because there are no public constructors for [`OutputContext`]. Similarly, the lack of a public `maybe_error_message` method requires a tedious workaround. This introduces several new methods to fix these deficiencies: - `OutputContext::new` lets you construct an `OutputContext`. - `OutputContext::into_output_and_command` lets you deconstruct an `OutputContext`. Previously, both these fields were accessible with `into_output` and `into_command`, but you could only call one of those methods, because they both take an owned `self` receiver. - `OutputContext::output_error` is like `OutputContext::error`, but it doesn't wrap the output in an `Error`, letting you use the `OutputError::with_message` method.
53f2d50 to
24d66bd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I learned it's actually impossible (!) for consumers to implement
CommandExtbecause there are no public constructors for [OutputContext]. Similarly, the lack of a publicmaybe_error_messagemethod requires a tedious workaround.This introduces several new methods to fix these deficiencies:
OutputContext::newlets you construct anOutputContext.OutputContext::into_output_and_commandlets you deconstruct anOutputContext. Previously, both these fields were accessible withinto_outputandinto_command, but you could only call one of those methods, because they both take an ownedselfreceiver.OutputContext::output_erroris likeOutputContext::error, but it doesn't wrap the output in anError, letting you use theOutputError::with_messagemethod.