Skip to content

Commit 9e29575

Browse files
committed
feat: Add TryFrom<Utf8PathBuf> for normalized paths
1 parent 36ad6ff commit 9e29575

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

src/extractors/normalized_path/absolute.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ impl TryFrom<String> for NormalizedPathAbsolute {
5858
}
5959
}
6060

61+
impl TryFrom<Utf8PathBuf> for NormalizedPathAbsolute {
62+
type Error = NormalizeError;
63+
64+
fn try_from(p: Utf8PathBuf) -> Result<Self, Self::Error> {
65+
Self::from_str(p.as_ref())
66+
}
67+
}
68+
6169
impl From<NormalizedPathAbsolute> for String {
6270
fn from(p: NormalizedPathAbsolute) -> Self {
6371
p.to_string()

src/extractors/normalized_path/component.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ impl TryFrom<String> for NormalizedPathComponent {
6565
}
6666
}
6767

68+
impl TryFrom<Utf8PathBuf> for NormalizedPathComponent {
69+
type Error = NormalizeError;
70+
71+
fn try_from(p: Utf8PathBuf) -> Result<Self, Self::Error> {
72+
Self::from_str(p.as_ref())
73+
}
74+
}
75+
6876
impl From<NormalizedPathComponent> for String {
6977
fn from(p: NormalizedPathComponent) -> Self {
7078
p.to_string()

src/extractors/normalized_path/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ impl TryFrom<String> for NormalizedPath {
137137
}
138138
}
139139

140+
impl TryFrom<Utf8PathBuf> for NormalizedPath {
141+
type Error = NormalizeError;
142+
143+
fn try_from(p: Utf8PathBuf) -> Result<Self, Self::Error> {
144+
Self::from_str(p.as_ref())
145+
}
146+
}
147+
140148
impl From<NormalizedPath> for String {
141149
fn from(p: NormalizedPath) -> Self {
142150
p.to_string()

src/extractors/normalized_path/relative.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ impl TryFrom<String> for NormalizedPathRelative {
5858
}
5959
}
6060

61+
impl TryFrom<Utf8PathBuf> for NormalizedPathRelative {
62+
type Error = NormalizeError;
63+
64+
fn try_from(p: Utf8PathBuf) -> Result<Self, Self::Error> {
65+
Self::from_str(p.as_ref())
66+
}
67+
}
68+
6169
impl From<NormalizedPathRelative> for String {
6270
fn from(p: NormalizedPathRelative) -> Self {
6371
p.to_string()

0 commit comments

Comments
 (0)