I have a function, which has special cases for 2 and 3 for some constant (number of splits in the tree). Starting from 4 there is a generic algorithm which is slower, but universal.
I want to have few implementations of my function for cases when constant is 2, 3, and for everything else.
I can do it with different names and match, but I feel that 'impl' is really good description of what I do.
Is there a way to (at type level) say that
impl Search for Tree when BRANCHES=2 {
...
}
impl Search for Tree when BRANCHES=3 {
...
}
impl Search for Tree {
// Generic implementation
}
I'm not really sure what BRANCHES is here. Is it a compile time constant? Perhaps you could use conditional compilation (something like #[cfg(BRANCHES = "2")].)