1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use std::{ops, path::Path};
use paths::{AbsPath, AbsPathBuf};
#[derive(Debug, Clone, PartialEq, Eq, Hash, Ord, PartialOrd)]
pub struct ManifestPath {
file: AbsPathBuf,
}
impl TryFrom<AbsPathBuf> for ManifestPath {
type Error = AbsPathBuf;
fn try_from(file: AbsPathBuf) -> Result<Self, Self::Error> {
if file.parent().is_none() {
Err(file)
} else {
Ok(ManifestPath { file })
}
}
}
impl ManifestPath {
pub fn parent(&self) -> &AbsPath {
self.file.parent().unwrap()
}
}
impl ops::Deref for ManifestPath {
type Target = AbsPath;
fn deref(&self) -> &Self::Target {
&*self.file
}
}
impl AsRef<Path> for ManifestPath {
fn as_ref(&self) -> &Path {
self.file.as_ref()
}
}