Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exp and windows: rethinking any matching #27

Closed
wants to merge 11 commits into from

Conversation

zhiburt
Copy link
Contributor

@zhiburt zhiburt commented Jun 19, 2020

@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 tuples Needle trait with implementation according to pick first logic.

There also was an idea creating a new struct(A, B, C) and a result enum(_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.

zhiburt and others added 11 commits May 26, 2020 22:32
Signed-off-by: Maxim Zhiburt <[email protected]>
Signed-off-by: Maxim Zhiburt <[email protected]>
Signed-off-by: Maxim Zhiburt <[email protected]>
draft of a possible solution to the rust-cli#14 issue and changes in public interface
Create a macros instead of the ABInterest solution.

The macros basically just tries to pull the result of every match. And
gives a end user a `match` like interface to cover all possible cases.

Signed-off-by: Maxim Zhiburt <[email protected]>
@matthiasbeyer
Copy link
Member

Hi! I am closing this PR now as it seems to be no longer relevant to you. Feel free to open a new one if you're still running into issues!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants