@@ -248,8 +248,8 @@ impl Config {
248
248
/// Sets the user to authenticate with.
249
249
///
250
250
/// Defaults to the user executing this process.
251
- pub fn user ( & mut self , user : & str ) -> & mut Config {
252
- self . user = Some ( user. to_string ( ) ) ;
251
+ pub fn user ( & mut self , user : impl Into < String > ) -> & mut Config {
252
+ self . user = Some ( user. into ( ) ) ;
253
253
self
254
254
}
255
255
@@ -277,8 +277,8 @@ impl Config {
277
277
/// Sets the name of the database to connect to.
278
278
///
279
279
/// Defaults to the user.
280
- pub fn dbname ( & mut self , dbname : & str ) -> & mut Config {
281
- self . dbname = Some ( dbname. to_string ( ) ) ;
280
+ pub fn dbname ( & mut self , dbname : impl Into < String > ) -> & mut Config {
281
+ self . dbname = Some ( dbname. into ( ) ) ;
282
282
self
283
283
}
284
284
@@ -289,8 +289,8 @@ impl Config {
289
289
}
290
290
291
291
/// Sets command line options used to configure the server.
292
- pub fn options ( & mut self , options : & str ) -> & mut Config {
293
- self . options = Some ( options. to_string ( ) ) ;
292
+ pub fn options ( & mut self , options : impl Into < String > ) -> & mut Config {
293
+ self . options = Some ( options. into ( ) ) ;
294
294
self
295
295
}
296
296
@@ -301,8 +301,8 @@ impl Config {
301
301
}
302
302
303
303
/// Sets the value of the `application_name` runtime parameter.
304
- pub fn application_name ( & mut self , application_name : & str ) -> & mut Config {
305
- self . application_name = Some ( application_name. to_string ( ) ) ;
304
+ pub fn application_name ( & mut self , application_name : impl Into < String > ) -> & mut Config {
305
+ self . application_name = Some ( application_name. into ( ) ) ;
306
306
self
307
307
}
308
308
@@ -330,15 +330,17 @@ impl Config {
330
330
/// Multiple hosts can be specified by calling this method multiple times, and each will be tried in order. On Unix
331
331
/// systems, a host starting with a `/` is interpreted as a path to a directory containing Unix domain sockets.
332
332
/// There must be either no hosts, or the same number of hosts as hostaddrs.
333
- pub fn host ( & mut self , host : & str ) -> & mut Config {
333
+ pub fn host ( & mut self , host : impl Into < String > ) -> & mut Config {
334
+ let host = host. into ( ) ;
335
+
334
336
#[ cfg( unix) ]
335
337
{
336
338
if host. starts_with ( '/' ) {
337
339
return self . host_path ( host) ;
338
340
}
339
341
}
340
342
341
- self . host . push ( Host :: Tcp ( host. to_string ( ) ) ) ;
343
+ self . host . push ( Host :: Tcp ( host) ) ;
342
344
self
343
345
}
344
346
@@ -990,7 +992,7 @@ impl<'a> UrlParser<'a> {
990
992
991
993
let mut it = creds. splitn ( 2 , ':' ) ;
992
994
let user = self . decode ( it. next ( ) . unwrap ( ) ) ?;
993
- self . config . user ( & user) ;
995
+ self . config . user ( user) ;
994
996
995
997
if let Some ( password) = it. next ( ) {
996
998
let password = Cow :: from ( percent_encoding:: percent_decode ( password. as_bytes ( ) ) ) ;
@@ -1053,7 +1055,7 @@ impl<'a> UrlParser<'a> {
1053
1055
} ;
1054
1056
1055
1057
if !dbname. is_empty ( ) {
1056
- self . config . dbname ( & self . decode ( dbname) ?) ;
1058
+ self . config . dbname ( self . decode ( dbname) ?) ;
1057
1059
}
1058
1060
1059
1061
Ok ( ( ) )
0 commit comments