@@ -86,26 +86,31 @@ impl<T: Into<failure::Error>> From<T> for ExitFailure {
8686/// ```rust,should_panic
8787/// # extern crate exitfailure;
8888/// # use exitfailure::ExitDisplay;
89- /// fn main() -> Result<(), ExitDisplay<String>> {
89+ /// fn main() -> Result<(), ExitDisplay> {
90+ /// some_other_fn()?;
9091/// Ok(some_fn()?)
9192/// }
9293///
93- /// fn some_fn() -> Result<(), String> {
94- /// Err("some error".into())
94+ /// fn some_fn() -> Result<(), &'static str> {
95+ /// Err("some error")
96+ /// }
97+ ///
98+ /// fn some_other_fn() -> Result<(), isize> {
99+ /// Ok(())
95100/// }
96101/// ```
97- pub struct ExitDisplay < E : std:: fmt:: Display > ( E ) ;
102+ pub struct ExitDisplay ( Box < dyn std:: fmt:: Display > ) ;
98103
99104/// Prints the underlying error type, using `Display` and not `Debug`.
100- impl < E : std:: fmt:: Display > std :: fmt :: Debug for ExitDisplay < E > {
105+ impl std:: fmt:: Debug for ExitDisplay {
101106 fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> std:: fmt:: Result {
102107 write ! ( f, "{}" , self . 0 )
103108 }
104109}
105110
106- impl < E : std:: fmt:: Display > From < E > for ExitDisplay < E > {
111+ impl < E : std:: fmt:: Display + ' static > From < E > for ExitDisplay {
107112 fn from ( e : E ) -> Self {
108- ExitDisplay ( e )
113+ ExitDisplay ( Box :: new ( e ) )
109114 }
110115}
111116
@@ -127,8 +132,8 @@ mod test {
127132 #[ test]
128133 fn test_exitdisplay ( ) {
129134 let mut buffer = String :: new ( ) ;
130- let error = "some error" . to_string ( ) ;
131- let exitdisplay: ExitDisplay < String > = error. into ( ) ;
135+ let error = "some error" ;
136+ let exitdisplay: ExitDisplay = error. into ( ) ;
132137 write ! ( buffer, "{:?}" , exitdisplay) . unwrap ( ) ;
133138 assert_eq ! ( buffer, "some error" ) ;
134139 }
0 commit comments