@@ -5,7 +5,7 @@ use serde_derive::{Deserialize, Serialize};
5
5
use std:: collections:: HashMap ;
6
6
use std:: mem;
7
7
8
- const DEFAULT : & ' static str = "DEFAULT" ;
8
+ const DEFAULT : & str = "DEFAULT" ;
9
9
10
10
#[ derive( Debug ) ]
11
11
pub struct Configuration {
@@ -140,7 +140,7 @@ impl App {
140
140
141
141
pub fn validate ( & self ) -> Result < ( ) > {
142
142
if let Some ( ts) = & self . targets {
143
- if ts. len ( ) == 0 {
143
+ if ts. is_empty ( ) {
144
144
bail ! ( ErrorKind :: MissingTargets ( self . name. clone( ) ) ) ;
145
145
}
146
146
} else {
@@ -239,14 +239,14 @@ impl Configuration {
239
239
}
240
240
}
241
241
242
- pub fn to_toml ( self ) -> Result < String > {
242
+ pub fn into_toml ( self ) -> Result < String > {
243
243
debug ! ( "Starting conversion to TOML" ) ;
244
244
let conf = TomlConfiguration :: from ( self ) ;
245
245
toml:: to_string ( & conf) . chain_err ( || "bad toml data" )
246
246
}
247
247
248
248
pub fn validate ( & self ) -> Result < ( ) > {
249
- for ( _name , app) in & self . apps {
249
+ for app in self . apps . values ( ) {
250
250
app. validate ( ) ?;
251
251
}
252
252
Ok ( ( ) )
@@ -374,19 +374,19 @@ impl ConfigurationBuilder {
374
374
Ok ( ( ) )
375
375
}
376
376
377
- fn convert_to_list ( & self , value : & String ) -> Vec < String > {
377
+ fn convert_to_list ( & self , value : & str ) -> Vec < String > {
378
378
let parts: Vec < _ > = value. split_whitespace ( ) . collect ( ) ;
379
379
parts. iter ( ) . map ( |s| s. to_string ( ) ) . collect ( )
380
380
}
381
381
382
- fn convert_to_bool ( & self , value : & String ) -> bool {
382
+ fn convert_to_bool ( & self , value : & str ) -> bool {
383
383
match & value[ ..] {
384
384
"false" | "False" | "FALSE" | "no" | "No" | "NO" => false ,
385
385
_ => true ,
386
386
}
387
387
}
388
388
389
- fn convert_to_pair_list ( & self , value : & String ) -> Result < Vec < Vec < String > > > {
389
+ fn convert_to_pair_list ( & self , value : & str ) -> Result < Vec < Vec < String > > > {
390
390
let mut iter = value. split_whitespace ( ) ;
391
391
let mut result = Vec :: new ( ) ;
392
392
loop {
@@ -395,7 +395,9 @@ impl ConfigurationBuilder {
395
395
result. push ( vec ! [ regex. to_string( ) , name. to_string( ) ] ) ;
396
396
}
397
397
( None , None ) => break ,
398
- _ => return Err ( ErrorKind :: BadInput ( "log_format.patterns" , value. clone ( ) ) . into ( ) ) ,
398
+ _ => {
399
+ return Err ( ErrorKind :: BadInput ( "log_format.patterns" , value. to_owned ( ) ) . into ( ) ) ;
400
+ }
399
401
}
400
402
}
401
403
Ok ( result)
0 commit comments