File tree 1 file changed +22
-1
lines changed
1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 1
- #[ derive( Copy , Clone , Debug ) ]
1
+ #[ derive( Copy , Clone ) ]
2
2
pub enum TockValue < E > {
3
3
Expected ( E ) ,
4
4
Unexpected ( isize ) ,
5
5
}
6
6
7
+ // Size-optimized implementation of Debug.
8
+ impl < E : core:: fmt:: Debug > core:: fmt:: Debug for TockValue < E > {
9
+ fn fmt ( & self , f : & mut core:: fmt:: Formatter ) -> Result < ( ) , core:: fmt:: Error > {
10
+ match self {
11
+ // Printing out the value of E would cause TockResult::unwrap() to
12
+ // use a &dyn core::fmt::Debug, which defeats LLVM's
13
+ // devirtualization and prevents LTO from removing unused Debug
14
+ // implementations. Unfortunately, that generates too much code
15
+ // bloat (several kB), so we cannot display the value contained in
16
+ // this TockValue.
17
+ TockValue :: Expected ( _) => f. write_str ( "Expected(...)" ) ,
18
+
19
+ TockValue :: Unexpected ( n) => {
20
+ f. write_str ( "Unexpected(" ) ?;
21
+ n. fmt ( f) ?;
22
+ f. write_str ( ")" )
23
+ }
24
+ }
25
+ }
26
+ }
27
+
7
28
pub type TockResult < T , E > = Result < T , TockValue < E > > ;
8
29
9
30
pub trait TockResultExt < T , E > : Sized {
You can’t perform that action at this time.
0 commit comments