@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 :)
@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.