Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove path type generic for better ergonomic #496

Merged
merged 2 commits into from
Jul 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions prost-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -698,10 +698,11 @@ impl Config {
/// Ok(())
/// }
/// ```
pub fn compile_protos<P>(&mut self, protos: &[P], includes: &[P]) -> Result<()>
where
P: AsRef<Path>,
{
pub fn compile_protos(
&mut self,
protos: &[impl AsRef<Path>],
includes: &[impl AsRef<Path>],
) -> Result<()> {
let target: PathBuf = self.out_dir.clone().map(Ok).unwrap_or_else(|| {
env::var_os("OUT_DIR")
.ok_or_else(|| {
Expand Down Expand Up @@ -915,10 +916,7 @@ impl fmt::Debug for Config {
/// [2]: http://doc.crates.io/build-script.html#case-study-code-generation
/// [3]: https://developers.google.com/protocol-buffers/docs/proto3#importing-definitions
/// [4]: https://developers.google.com/protocol-buffers/docs/proto#packages
pub fn compile_protos<P>(protos: &[P], includes: &[P]) -> Result<()>
where
P: AsRef<Path>,
{
pub fn compile_protos(protos: &[impl AsRef<Path>], includes: &[impl AsRef<Path>]) -> Result<()> {
Config::new().compile_protos(protos, includes)
}

Expand Down
5 changes: 2 additions & 3 deletions protobuf/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ fn main() -> Result<()> {
.iter()
.map(|proto| datasets_include_dir.join(proto)),
);
prost_build::compile_protos(&benchmark_protos, &[benchmarks_include_dir.to_path_buf()])
.unwrap();
prost_build::compile_protos(&benchmark_protos, &[benchmarks_include_dir]).unwrap();

let conformance_include_dir = include_dir.join("conformance");
prost_build::compile_protos(
Expand All @@ -91,7 +90,7 @@ fn main() -> Result<()> {
test_includes.join("test_messages_proto3.proto"),
test_includes.join("unittest.proto"),
],
&[include_dir.to_path_buf()],
&[include_dir],
)
.unwrap();

Expand Down
2 changes: 1 addition & 1 deletion tests/src/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn bootstrap() {
protobuf.join("timestamp.proto"),
protobuf.join("type.proto"),
],
&[],
&[""],
)
.unwrap();

Expand Down