Skip to content

Commit

Permalink
feat: TryFrom<&OsStr> to allow direct usage of Url in clap. (#450)
Browse files Browse the repository at this point in the history
In `clap_derive`, this needs
`parse(try_from_os_str = std::convert::TryFrom::try_from)`.
  • Loading branch information
Byron committed Aug 22, 2022
1 parent b7a5f7a commit 7a17690
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions git-url/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,17 @@ impl TryFrom<PathBuf> for Url {
}
}

impl TryFrom<&std::ffi::OsStr> for Url {
type Error = parse::Error;

fn try_from(value: &std::ffi::OsStr) -> Result<Self, Self::Error> {
use std::convert::TryInto;
git_path::os_str_into_bstr(value)
.expect("no illformed UTF-8 on Windows")
.try_into()
}
}

impl TryFrom<&BStr> for Url {
type Error = parse::Error;

Expand Down

0 comments on commit 7a17690

Please sign in to comment.