Skip to content

Commit

Permalink
Use AsRef<Path> for bindgen::generate
Browse files Browse the repository at this point in the history
  • Loading branch information
eqrion committed Sep 27, 2017
1 parent bf1ef33 commit 6551eea
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,16 @@ use std::path::Path;

/// A utility function for build scripts to generate bindings for a crate, using
/// a `cbindgen.toml` if it exists.
pub fn generate(crate_dir: &str) -> Result<Bindings, String> {
let config = Config::from_root_or_default(Path::new(crate_dir));
pub fn generate<P: AsRef<Path>>(crate_dir: P) -> Result<Bindings, String> {
let config = Config::from_root_or_default(crate_dir.as_ref());

generate_with_config(crate_dir, config)
}

/// A utility function for build scripts to generate bindings for a crate with a
/// custom config.
pub fn generate_with_config(crate_dir: &str, config: Config) -> Result<Bindings, String> {
let crate_dir = Path::new(crate_dir);
let cargo = Cargo::load(crate_dir,
pub fn generate_with_config<P: AsRef<Path>>(crate_dir: P, config: Config) -> Result<Bindings, String> {
let cargo = Cargo::load(crate_dir.as_ref(),
None,
config.parse.parse_deps)?;

Expand Down

0 comments on commit 6551eea

Please sign in to comment.