subscriber: Replace OFF with None in empty Vec max_level_hint#3564
Open
nicopap wants to merge 1 commit into
Open
subscriber: Replace OFF with None in empty Vec max_level_hint#3564nicopap wants to merge 1 commit into
nicopap wants to merge 1 commit into
Conversation
The expected behavior of adding an empty Vec as Layer is that it does nothing. Right now, it adds a LevelFilter::OFF rule, thus supressing other layers. This change makes max_level_hint return None, which doesn't supress other layers, following expected behavior. * Fixes tokio-rs#3563 * This is a breaking change (no API change, but observable behavior)
Author
|
Is there some actions I should be doing, or is it just that the review bandwidth is saturated? Asking not out of frustration (the maintainers should go at their own pace and I'm not entitled to anything), but rather out of concern that I'm not making everything to make the reviewer's job easier. |
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.
The expected behavior of adding an empty Vec as Layer is that it does nothing. Right now, it adds a LevelFilter::OFF rule, thus supressing other layers.
This change makes max_level_hint return None, which doesn't supress other layers, following expected behavior.
<Vec as Layer>::max_level_hintbe OFF when Vec is empty? #3563Motivation
<Vec as Layer>::max_level_hintbe OFF when Vec is empty? #3563Solution
We return
Nonewhen the vec is empty.Details
The one-liner: cute solution, but might not be obvious how it works at first glance:
LevelFilter, but we want theNonecase to be even higher priority than other.Ordimpl ofOptionmakesNonethe lowest possible value. Solution: We usemininstead ofmax!LevelFilter. Solution: We use.map(Reverse)so thatminforLevelFilteris equivalent tomax!Some(x??.0)