Module 8Cargo & ModulesLesson 3 of 716 min
Visibility & API Design
pub, pub(crate), and keeping internals private.
Visibility
- default: private to module
- pub: visible outside
- pub(crate): visible in crate only
Good quant API
Expose: price, greeks, validate
Hide: raw CDF coefficients, scratch buffers
Challenge
Sketch module tree comments for bs, mc, risk in a string printout.
Tips
- Private by default
- Small public surface
- Helpers stay internal
Try it live
Visibility & API DesignRust 2021
Loading editor…
Output
Press Run to compile and execute.