Module system examples
futures-rs
  • Public surface
  • Several submodules, no nesting within them
  • Several type definitions and re-exports
  • Internal surface
  • many nested modules for file organization and namespacing
  • generally each provides one or two definitions that are re-exported by the parent

regex
  • Public surface
  • Almost entirely flat, except bytes submodule (which is like an entire alternative API surface)
  • Internal surface
  • flat
  • seemingly mostly for file organization
  • some use of privacy

rayon
  • Public surface
  • Quite a few submodules, with further nesting within them
  • The nested submodules are very small — most define Iter and IntoIter for particular types
  • These definitions would not need to be exposed if we had impl Trait in trait impls
  • Could also just re-organize these into a single submodule
  • Several functions and types defined at top level
  • Internal surface
  • Many public submodules are just files
  • These are mixed with files that do not define public submodules, making it difficult to discern the module structure
  • This seems to come down to the impl Trait issue above
  • test.rs at root level

log
  • Public surface
  • No submodules
  • Internal surface
  • Just one file

openssl
  • Public surface
  • Many submodules at root, no nesting
  • Only one function at top level
  • Internal surface
  • Mostly flat list of files
  • Most correspond to public submodules, but some do not

flate2
  • Public surface
  • A few submodules, each of which contains a bunch of types
  • Several definitions at top level
  • Internal surface
  • Directory/file structure doesn’t match public API surface at all