Get rid of Chain as the building block for other combinators and remo… #2117
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.
…ve some unsafe code
This is just the first step in a potential refactor that could remove a lot of safe and unsafe code, and I wanted to test the waters before going all out. As you can see the amount of code that can be deleted this way is high!
The basic ideas are:
pin-utils
topin-project
as it has a safe API and supports enums, which results in smaller combinator sizes in memory.Chain
as it is unnecessarily complicated. We can instead build up from primitive combinators likeFlatten
andMap
.There are a couple of open questions:
Is it OK to use raw type aliases as I have done with
Then
? Strictly speaking, it's a breaking change, however, it's exceptionally unlikely that it will actually cause any problems. If we don't want to do this, the fallback would be to have a macro to define a load of newtype wrappers that automatically implement the relevant traits.Is it OK to get rid of the unused type parameter on
Then
? This is a breaking change, although you wouldn't typically name this parameter during normal usage. If we don't want to get rid of it, then we'll need a newtype wrapper for at leastThen
and any other combinators with unused generic parameters.