C and C++ must use #include
due to the lacks of a module system, but Rust already has a module system that is superior to include!
in every way. I can't think of any legit use of include!
or why is it even necessary.
It can be used to include a source file whose name or location is determined at build time, for example by an environment variable or build.rs script. This is especially common with crates that generate code at build time:
https://doc.rust-lang.org/cargo/reference/build-script-examples.html#code-generation
3 Likes
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.