Hi, I am working on a library, I'd like to do something like the following in Rust:
template <size_t param>
class A {
public:
void method(void) {
// uses `param` which gets inlined.
}
};
Probably, it has been asked before but I can't find anything related. What's the best way to approach this? Is it using macro_rules? Are there any libraries that I could take a look at that do something similar?
We are working on const generics, which is a similar feature to this. It's not ready for prime time though; an initial implementation is in nightly, but there's a lot more work to do.
Thanks for the reply! I have tried something similar using an enum instead of a struct ONE in a case where PARAM was taking a small number of values. If I understand correctly this uses the type (struct ONE) to do specialization and not the PARAM's value.