Exp and windows: rethinking any matching #27
Closed
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.
@philippkeller this PR provides changes according to the last comments in #24.
You can diff it against the exp_and_windows branch to see the changes or look at the
d9f868b commit.
Expanding the macros produces plain
if/else
structure.One of possible ways to keep an interface 'pretty clean' is to create a macros instead of providing ABInterest and or stuff. There still no additional copies and using index which allows to rely on the idea that all path of code are covered.
I didn't test the macros highly.
For 2 days I was thinking about what type of macro could help here and came with that.
One of possible solutions could be usage of tuple
(A, B)
and implementing for a reasonable number of tuplesNeedle
trait with implementation according topick first
logic.There also was an idea creating a new
struct(A, B, C)
and a resultenum(_1(AResult), _2(BResult), _3(CResult))
by macros including a fact that it will shadowing in in internal scope it will be OK and would work but ...... I tried it and didn't manage to do that. What's more to notice in this approach creates a 'generable' enum variants which is not so perfect. And truly saying I am not even possible if it's possible to be done by macros in rust.The problem with using some structure like
Vec<dyn Needle>
is that here we should specify a associative type. But we can't spicify it to something dynamic as I understand. That's why returning an index is not so simple :)I've not found a better solution yet.