Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 22d3b37

Browse files
committed
feat: Url::try_from(path: &std::path::Path) for more convenient instantiation.
1 parent a1068a3 commit 22d3b37

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

git-repository/src/clone.rs

Whitespace-only changes.

git-repository/tests/clone/mod.rs

Whitespace-only changes.

git-url/src/impls.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
use std::{convert::TryFrom, path::PathBuf};
1+
use std::{
2+
convert::TryFrom,
3+
path::{Path, PathBuf},
4+
};
25

36
use bstr::BStr;
47

@@ -42,6 +45,15 @@ impl TryFrom<PathBuf> for Url {
4245
}
4346
}
4447

48+
impl TryFrom<&Path> for Url {
49+
type Error = parse::Error;
50+
51+
fn try_from(value: &Path) -> Result<Self, Self::Error> {
52+
use std::convert::TryInto;
53+
git_path::into_bstr(value).try_into()
54+
}
55+
}
56+
4557
impl TryFrom<&std::ffi::OsStr> for Url {
4658
type Error = parse::Error;
4759

0 commit comments

Comments
 (0)