Refine Guard* APIs and implementation
#11354
Merged
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.
This is a follow-up to #11325 with a number of cosmetic changes about
the shape of the API and structure of the internals:
{Stream,Future}{Reader,Writer}::guardis now an alternativeconstructor to
Guard*::new(import fewer types).WithAccessorandDropWithStoreare removed in favor ofdirect
Drop for Guard*impls.Optionis used to replaceManuallyDropandunsafecode.{Stream,Future}{Reader,Writer}::close{,_with}now take&mut selfinstead of
selfto be more composable with&mut selfargumentsduring
Dropfor other structures (e.g. build-your-owndrop-with-store).
Guard*are simplified to justT, the futureor stream payload, and
A: AsAccessor. This helps cut down on thecomplexity of signatures.
Guard*types now haveinto_{stream,future}as an alternative to.into()which doesn't require type annotations.