How to automatically expose all .rs files in a directory in a module?

后端 未结 1 856
刺人心
刺人心 2021-01-27 01:49

I have module files generated from protobuf definitions. There are a lot of files and they will grow with time. This is the structure:



        
相关标签:
1条回答
  • 2021-01-27 02:04

    Use dtolnay's automod crate.

    automod::dir!("path/to/directory"); 
    

    This macro expands to one or more mod items, one for each source file in the specified directory.

    The path is given relative to the directory containing Cargo.toml.

    0 讨论(0)
提交回复
热议问题