Skip to content

Commit

Permalink
Remove path type generic for better ergonomic (#496)
Browse files Browse the repository at this point in the history
* Remove path type generic for better ergonomic

* Workaround empty type issue
  • Loading branch information
aquarhead committed Jul 6, 2021
1 parent 5d93c55 commit 4ae66cc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
14 changes: 6 additions & 8 deletions prost-build/src/lib.rs
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
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
Expand Up @@ -40,7 +40,7 @@ fn bootstrap() {
protobuf.join("timestamp.proto"),
protobuf.join("type.proto"),
],
&[],
&[""],
)
.unwrap();

Expand Down

0 comments on commit 4ae66cc

Please sign in to comment.