So, the function accepts two values that implement Mid trait. And there is a blanket implementation for Mid that applies to anything can be added, substracted, divided etc and can be derived from a u8. So now this will make every numeric type a Mid. (Which, as the author states only an example I guess)
I can read and understand how this works here. But when I’m in a larger code base, I can not find what trait implementation made what possible.
With all the trait bounds and implicit conversions happening around and macros implementing traits on stuff it becomes a shit stew in a hurry.
And everyone always reaches to the most clever way to do things. I mean, does Mid need to be a trait? I guess it works beautifully yeah. I’d prefer to pass a midpoint calculator function instead.
I guess this turned into a rant. I actually really like Rust the language but I think I don’t like Rust codebases basically.
It is the least readable language I’ve seen not because of the syntax but because of all the cleverness going on around the traits and macros.