-
Notifications
You must be signed in to change notification settings - Fork 8
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
Implement Median
for slice types with macro
#274
Conversation
Dang is there really no good trait combo to describe "numbers"? I am a macro noob so I am gonna just play around with this one to learn it. |
I would say a number is described by the following ref: https://internals.rust-lang.org/t/please-can-we-add-a-basic-num-trait/16449 |
Wow yea. I guess we could shove that in an alias and boil it down to just the bare minimum requirement for the function (which could be what you have already), but we till wouldn't get away from the weird |
Either |
Yea, I still find the macro syntax wierd, but that is me just not knowing. I think the macro is essentially doing what the compiler would too for the trait bound? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK 73beeaa
I am gonna take some time to finally learn macros
Yeah, the compiler will re-implement the trait for each type that ends up using it |
73beeaa
to
da95db5
Compare
Attempting to remove the repeated logic here, but also trying to avoid the trait hell that is required for implementing
Median
in a generic way. I extracted the logic into a macro which is reusable for any type of interest to implementMedian
cc @nyonson