Share code between build script and resultant library


I have a build script that parses some data and generates code from it. The resultant library also needs to parse the same kind of data as the build script parses, so I want to share the parsing code between the build script and the library. What is the best way to go about doing this?


If it is feasible to the parsing logic into an separate crate and then use it as both a build and normal dependency, that would be the best way.


I agree with @huon, but just to provide an alternative: Both the build script and the library could import the same source file as a module, using:

#[path = "path/to/"]
mod shared;