@@ -39,48 +39,44 @@ pub struct VersionInfo {
39
39
}
40
40
41
41
impl std:: fmt:: Display for VersionInfo {
42
- fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> std:: fmt:: Result {
43
- match self . commit_hash {
44
- Some ( _) => {
45
- write ! (
46
- f,
47
- "{} {}.{}.{} ({} {})" ,
48
- self . crate_name,
49
- self . major,
50
- self . minor,
51
- self . patch,
52
- self . commit_hash. clone( ) . unwrap_or_default( ) . trim( ) ,
53
- self . commit_date. clone( ) . unwrap_or_default( ) . trim( ) ,
54
- ) ?;
55
- } ,
56
- None => {
57
- write ! ( f, "{} {}.{}.{}" , self . crate_name, self . major, self . minor, self . patch) ?;
58
- } ,
59
- } ;
42
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
43
+ if self . commit_hash . is_some ( ) {
44
+ write ! (
45
+ f,
46
+ "{} {}.{}.{} ({} {})" ,
47
+ self . crate_name,
48
+ self . major,
49
+ self . minor,
50
+ self . patch,
51
+ self . commit_hash. clone( ) . unwrap_or_default( ) . trim( ) ,
52
+ self . commit_date. clone( ) . unwrap_or_default( ) . trim( ) ,
53
+ ) ?;
54
+ } else {
55
+ write ! ( f, "{} {}.{}.{}" , self . crate_name, self . major, self . minor, self . patch) ?;
56
+ }
57
+
60
58
Ok ( ( ) )
61
59
}
62
60
}
63
61
64
62
impl std:: fmt:: Debug for VersionInfo {
65
- fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> std:: fmt:: Result {
63
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
66
64
write ! (
67
65
f,
68
66
"VersionInfo {{ crate_name: \" {}\" , major: {}, minor: {}, patch: {}" ,
69
67
self . crate_name, self . major, self . minor, self . patch,
70
68
) ?;
71
- match self . commit_hash {
72
- Some ( _) => {
73
- write ! (
74
- f,
75
- ", commit_hash: \" {}\" , commit_date: \" {}\" }}" ,
76
- self . commit_hash. clone( ) . unwrap_or_default( ) . trim( ) ,
77
- self . commit_date. clone( ) . unwrap_or_default( ) . trim( )
78
- ) ?;
79
- } ,
80
- None => {
81
- write ! ( f, " }}" ) ?;
82
- } ,
69
+ if self . commit_hash . is_some ( ) {
70
+ write ! (
71
+ f,
72
+ ", commit_hash: \" {}\" , commit_date: \" {}\" }}" ,
73
+ self . commit_hash. clone( ) . unwrap_or_default( ) . trim( ) ,
74
+ self . commit_date. clone( ) . unwrap_or_default( ) . trim( )
75
+ ) ?;
76
+ } else {
77
+ write ! ( f, " }}" ) ?;
83
78
}
79
+
84
80
Ok ( ( ) )
85
81
}
86
82
}
0 commit comments