fix(filter): return AsyncFilterLayer from AsyncFilter::layer#875
Open
ameyypawar wants to merge 1 commit into
Open
fix(filter): return AsyncFilterLayer from AsyncFilter::layer#875ameyypawar wants to merge 1 commit into
ameyypawar wants to merge 1 commit into
Conversation
`AsyncFilter::layer` is documented to wrap services with an `AsyncFilter` service built from an `AsyncPredicate`, but it returned a `FilterLayer` — which builds a synchronous `Filter` from a `Predicate` — making the constructor unusable for its stated purpose. Return `AsyncFilterLayer` instead, mirroring `Filter::layer`.
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.
Summary
Fixes #597.
AsyncFilter::layeris documented to wrap services with anAsyncFilterbuilt from anAsyncPredicate, but it returnedFilterLayer<U>— the synchronous layer, which builds aFilterfrom a syncPredicate:This is a copy/paste slip from the original filter rework (#508) —
AsyncFilter::layerproduced a layer that builds the wrong service type, making the constructor unusable for its stated purpose (anAsyncPredicatedoesn't satisfyFilterLayer's syncPredicatebound). It now mirrorsFilter::layer.This changes the public return type of
AsyncFilter::layerfromFilterLayer<U>toAsyncFilterLayer<U>, so it's technically a semver-breaking change. In practice no working code could have depended on the old return — aFilterLayerbuilt from anAsyncPredicatedoesn't implementLayerusefully (the predicate doesn't satisfy the syncPredicatebound). Flagging it so you can decide whether it rides a minor release or a0.6. (Ref: the original report notes @hawkw considered it likely fine for a minor.)Notes
AsyncFilterLayer::newhas the same signature asFilterLayer::new, andAsyncFilterLayer'sLayerimpl producesAsyncFilter<S, U>— so the corrected method is consistent with the rest of the module.layernon-constto match the siblingFilter::layer(both are non-consteven though the underlying*Layer::newconstructors areconst).cargo check --workspace --all-features --all-targetsand the doc-test suite both pass, so the return-type change breaks no call sites.I left this as the focused one-line fix; happy to add a doc/
check_service-style test demonstratingAsyncFilter::layerbuilds a working async filter if you'd like one in this PR.