OutputContext: Add new, into_output_and_command, and output_error
#28
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.