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
use bstr::BStr;
use git_hash::oid;
use crate::{Kind, Target};
impl<'a> Target<'a> {
pub fn kind(&self) -> Kind {
match self {
Target::Symbolic(_) => Kind::Symbolic,
Target::Peeled(_) => Kind::Peeled,
}
}
pub fn as_id(&self) -> Option<&oid> {
match self {
Target::Symbolic(_) => None,
Target::Peeled(oid) => Some(oid),
}
}
pub fn as_name(&self) -> Option<&BStr> {
match self {
Target::Symbolic(path) => Some(path),
Target::Peeled(_) => None,
}
}
pub fn to_owned(self) -> crate::mutable::Target {
self.into()
}
}