0

I use doc tests whenever reasonable for a number of reasons (locality, serves as an example, etc). I would like to use doc tests for functions and methods that are not marked pub. I figure this would probably involve using #[cfg(test)] in appropriate places, but I'm not sure.

How would you mark functions and methods so that they can be used in doc tests?

Willi Ballenthin
  • 6,444
  • 6
  • 38
  • 52
  • 1
    It looks like your question might be answered by the answers of [How to write documentation tests for an internal API?](https://stackoverflow.com/q/47698062/155423); [How do I change a function's qualifiers via conditional compilation?](https://stackoverflow.com/q/49479854/155423). If not, please **[edit]** your question to explain the differences. Otherwise, we can mark this question as already answered. – Shepmaster Sep 10 '19 at 16:41
  • 1
    See also [Can I make an object public for integration tests and/or benchmarks only?](https://stackoverflow.com/q/47698194/155423). [Conditional visibility for unit tests](https://stackoverflow.com/q/51884807/155423) appears to be the same and was marked as a duplicate of one of the earlier suggestions. – Shepmaster Sep 10 '19 at 16:42
  • 1
    @Shepmaster thanks for the links. I agree that these answers are probably sufficient to answer my question. Thanks! – Willi Ballenthin Sep 10 '19 at 16:46

0 Answers0