Can end-user employ functions defined in unit tests?

Hi,

I'm discovering a lib availaible on github. I'm interested by functions defined in its unit-tests because I don't find any example elsewhere how to use the lib. I understand it is not primary goal of these functions to be usable by end-user. But, I would like to know if there is a way to use them cleanly if possible rather than copy-paste snippets. If it is only a bad practice, how do you proceed in a similar case?

1 Like

They're not exposed to users, and they're not even compiled when you use the project as a dependency.

Copy'n'paste them.

In the same lib, I read:

#[test]
pub fn foo() {}

The function is not exposed to users but it is public. It seems contradictory at first view. I guess it stems from a bad practice to put "pub" everywhere. Can it be legitimate to define a pub function after #[test] annotation?

Putting pub on a test doesn't really do anything. :woman_shrugging:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.