@@ -157,21 +157,21 @@ pub struct Error {
157
157
/// Describes the kind of error that occurred.
158
158
kind : ErrorKind ,
159
159
/// More explanation of error that occurred.
160
- message : String ,
160
+ message : Cow < ' static , str > ,
161
161
}
162
162
163
163
impl Error {
164
- fn new ( kind : ErrorKind , message : & str ) -> Error {
164
+ fn new ( kind : ErrorKind , message : impl Into < Cow < ' static , str > > ) -> Error {
165
165
Error {
166
- kind : kind ,
167
- message : message. to_owned ( ) ,
166
+ kind,
167
+ message : message. into ( ) ,
168
168
}
169
169
}
170
170
}
171
171
172
172
impl From < io:: Error > for Error {
173
173
fn from ( e : io:: Error ) -> Error {
174
- Error :: new ( ErrorKind :: IOError , & format ! ( "{}" , e) )
174
+ Error :: new ( ErrorKind :: IOError , format ! ( "{}" , e) )
175
175
}
176
176
}
177
177
@@ -2242,7 +2242,7 @@ impl Build {
2242
2242
let arch = target. split ( '-' ) . nth ( 0 ) . ok_or_else ( || {
2243
2243
Error :: new (
2244
2244
ErrorKind :: ArchitectureInvalid ,
2245
- format ! ( "Unknown architecture for {} target." , os) . as_str ( ) ,
2245
+ format ! ( "Unknown architecture for {} target." , os) ,
2246
2246
)
2247
2247
} ) ?;
2248
2248
@@ -2292,7 +2292,7 @@ impl Build {
2292
2292
_ => {
2293
2293
return Err ( Error :: new (
2294
2294
ErrorKind :: ArchitectureInvalid ,
2295
- format ! ( "Unknown architecture for {} target." , os) . as_str ( ) ,
2295
+ format ! ( "Unknown architecture for {} target." , os) ,
2296
2296
) ) ;
2297
2297
}
2298
2298
}
@@ -3147,7 +3147,7 @@ impl Build {
3147
3147
Some ( s) => Ok ( s) ,
3148
3148
None => Err ( Error :: new (
3149
3149
ErrorKind :: EnvVarNotFound ,
3150
- & format ! ( "Environment variable {} not defined." , v. to_string ( ) ) ,
3150
+ format ! ( "Environment variable {} not defined." , v) ,
3151
3151
) ) ,
3152
3152
}
3153
3153
}
@@ -3167,7 +3167,7 @@ impl Build {
3167
3167
Some ( res) => Ok ( res) ,
3168
3168
None => Err ( Error :: new (
3169
3169
ErrorKind :: EnvVarNotFound ,
3170
- & format ! ( "Could not find environment variable {}." , var_base) ,
3170
+ format ! ( "Could not find environment variable {}." , var_base) ,
3171
3171
) ) ,
3172
3172
}
3173
3173
}
@@ -3480,7 +3480,7 @@ fn wait_on_child(cmd: &Command, program: &str, child: &mut Child) -> Result<(),
3480
3480
Err ( e) => {
3481
3481
return Err ( Error :: new (
3482
3482
ErrorKind :: ToolExecError ,
3483
- & format ! (
3483
+ format ! (
3484
3484
"Failed to wait on spawned child process, command {:?} with args {:?}: {}." ,
3485
3485
cmd, program, e
3486
3486
) ,
@@ -3494,7 +3494,7 @@ fn wait_on_child(cmd: &Command, program: &str, child: &mut Child) -> Result<(),
3494
3494
} else {
3495
3495
Err ( Error :: new (
3496
3496
ErrorKind :: ToolExecError ,
3497
- & format ! (
3497
+ format ! (
3498
3498
"Command {:?} with args {:?} did not execute successfully (status code {})." ,
3499
3499
cmd, program, status
3500
3500
) ,
@@ -3559,12 +3559,12 @@ fn spawn(cmd: &mut Command, program: &str, pipe_writer: File) -> Result<Child, E
3559
3559
} ;
3560
3560
Err ( Error :: new (
3561
3561
ErrorKind :: ToolNotFound ,
3562
- & format ! ( "Failed to find tool. Is `{}` installed?{}" , program, extra) ,
3562
+ format ! ( "Failed to find tool. Is `{}` installed?{}" , program, extra) ,
3563
3563
) )
3564
3564
}
3565
3565
Err ( e) => Err ( Error :: new (
3566
3566
ErrorKind :: ToolExecError ,
3567
- & format ! (
3567
+ format ! (
3568
3568
"Command {:?} with args {:?} failed to start: {:?}" ,
3569
3569
cmd. 0 , program, e
3570
3570
) ,
0 commit comments