Include files into crate using cargo


#1

Is there a way to include files (sql, etc.) from my /src directory into the compiled output (target / release driectory)? So they kind oft just get copied? Or even put into the binary?


#2

You can always do it in the build script. Not exactly convenient though.

You can either copy the files or you can convert them to rust source defining static array or string with appropriate literal and import them to the main source.


#3

You can do that with the include_str! or include_bytes! macro. See for example.