Open theochap opened 1 year ago
I can take this issue if people think that's useful enough!
I think it can be a good idea. @theochap , could you give one or several concrete examples where it would be useful? I am asking, because this solution might bring some burden on test maintenance, because changin private methods can potentially break the tests. Usually it is a good question to ask, why test require access to private fields? If it is black-box testing, then it should be possible to check correctness using public methods. Maybe design of public methods require adjustments?
Also, this only work inside crate, because even in test, other crates are not compiled for testing. Then it means that pub(crate)
might be useful to have
I think practical uses for such macro would be limited and there's several 3rd-party crates that do this already; we could use any of those if this ever becomes necessary. I propose closing this issue.
Description
When testing data structures, we often need to generate public getters to get (normally) private elements of data structures. This issue offers to add a macro that would automatically generate getters for test configuration for the data structures where it is applied.
Example
For the data structure
SlotCommit
:The macro would generate