Is there any way to allow the tests in the
tests/ folder to access
One of the major problems I run into with Rust is that I am not able to test internal functions from the
tests/ folder without adding the function to the library’s public API, which I do not want.
Now the problem is that I have about 500 lines of code split up into 2 files. The functions in these two files are responsible to parse a regex and return an ast for the regex. However, I also have about 780 lines of tests, which test a single function, the function responsible to orchestrate the regex parsing, and it’s result, the ast.
Since the libraries overall goal is to write a regex engine I do not want to add the parsing function to the public api. But the current alternative to adding the function to the public interface, is to have the file with the parsing function be more than 1000 lines of code. Which I find to be even worse (- and it is a problem, which I face in most of my crates).
What is the correct way to deal with these kind of tests? I would just love to make these functions
pub(crate) and then be able test them from within the
test/ folder, is there a way to do that? (And why is Rust not allowing that?)