File tree Expand file tree Collapse file tree 1 file changed +34
-1
lines changed Expand file tree Collapse file tree 1 file changed +34
-1
lines changed Original file line number Diff line number Diff line change 1
1
use crate :: Time ;
2
2
use bstr:: BStr ;
3
3
use quick_error:: quick_error;
4
- use std:: str;
4
+ use std:: { convert :: TryFrom , str} ;
5
5
6
6
pub ( crate ) mod commit;
7
7
pub ( crate ) mod tag;
@@ -83,6 +83,39 @@ impl<'data> Object<'data> {
83
83
}
84
84
}
85
85
86
+ impl < ' data > From < Tag < ' data > > for Object < ' data > {
87
+ fn from ( v : Tag < ' data > ) -> Self {
88
+ Object :: Tag ( v)
89
+ }
90
+ }
91
+ impl < ' data > From < Commit < ' data > > for Object < ' data > {
92
+ fn from ( v : Commit < ' data > ) -> Self {
93
+ Object :: Commit ( v)
94
+ }
95
+ }
96
+
97
+ impl < ' data > TryFrom < Object < ' data > > for Tag < ' data > {
98
+ type Error = Object < ' data > ;
99
+
100
+ fn try_from ( value : Object < ' data > ) -> Result < Self , Self :: Error > {
101
+ Ok ( match value {
102
+ Object :: Tag ( v) => v,
103
+ _ => return Err ( value) ,
104
+ } )
105
+ }
106
+ }
107
+
108
+ impl < ' data > TryFrom < Object < ' data > > for Commit < ' data > {
109
+ type Error = Object < ' data > ;
110
+
111
+ fn try_from ( value : Object < ' data > ) -> Result < Self , Self :: Error > {
112
+ Ok ( match value {
113
+ Object :: Commit ( v) => v,
114
+ _ => return Err ( value) ,
115
+ } )
116
+ }
117
+ }
118
+
86
119
#[ derive( PartialEq , Eq , Debug , Hash ) ]
87
120
pub struct Signature < ' data > {
88
121
pub name : & ' data BStr ,
You can’t perform that action at this time.
0 commit comments