File tree Expand file tree Collapse file tree 1 file changed +19
-17
lines changed Expand file tree Collapse file tree 1 file changed +19
-17
lines changed Original file line number Diff line number Diff line change @@ -152,24 +152,26 @@ pub trait ErrorDomain: Copy {
152
152
/// Generic error used for functions that fail without any further information
153
153
#[ macro_export]
154
154
macro_rules! bool_error(
155
- // Plain strings
156
- ( $msg: expr) => { {
157
- $crate:: BoolError :: new(
158
- $msg,
159
- file!( ) ,
160
- $crate:: function_name!( ) ,
161
- line!( ) ,
162
- )
163
- } } ;
164
-
165
- // Format strings
166
155
( $( $msg: tt) * ) => { {
167
- $crate:: BoolError :: new(
168
- format!( $( $msg) * ) ,
169
- file!( ) ,
170
- $crate:: function_name!( ) ,
171
- line!( ) ,
172
- )
156
+ match :: std:: format_args!( $( $msg) * ) {
157
+ formatted => {
158
+ if let Some ( s) = formatted. as_str( ) {
159
+ $crate:: BoolError :: new(
160
+ s,
161
+ file!( ) ,
162
+ $crate:: function_name!( ) ,
163
+ line!( )
164
+ )
165
+ } else {
166
+ $crate:: BoolError :: new(
167
+ formatted. to_string( ) ,
168
+ file!( ) ,
169
+ $crate:: function_name!( ) ,
170
+ line!( ) ,
171
+ )
172
+ }
173
+ }
174
+ }
173
175
} } ;
174
176
) ;
175
177
You can’t perform that action at this time.
0 commit comments