Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitded5e7d

Browse files
authored
Merge pull requestrust-postgres#1137 from nyurik/use-string
Avoid extra clone in config if possible
2 parents34a68c0 +3c6dbe9 commitded5e7d

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

‎tokio-postgres/src/config.rs‎

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ impl Config {
248248
/// Sets the user to authenticate with.
249249
///
250250
/// Defaults to the user executing this process.
251-
pubfnuser(&mutself,user:&str) ->&mutConfig{
252-
self.user =Some(user.to_string());
251+
pubfnuser(&mutself,user:implInto<String>) ->&mutConfig{
252+
self.user =Some(user.into());
253253
self
254254
}
255255

@@ -277,8 +277,8 @@ impl Config {
277277
/// Sets the name of the database to connect to.
278278
///
279279
/// Defaults to the user.
280-
pubfndbname(&mutself,dbname:&str) ->&mutConfig{
281-
self.dbname =Some(dbname.to_string());
280+
pubfndbname(&mutself,dbname:implInto<String>) ->&mutConfig{
281+
self.dbname =Some(dbname.into());
282282
self
283283
}
284284

@@ -289,8 +289,8 @@ impl Config {
289289
}
290290

291291
/// Sets command line options used to configure the server.
292-
pubfnoptions(&mutself,options:&str) ->&mutConfig{
293-
self.options =Some(options.to_string());
292+
pubfnoptions(&mutself,options:implInto<String>) ->&mutConfig{
293+
self.options =Some(options.into());
294294
self
295295
}
296296

@@ -301,8 +301,8 @@ impl Config {
301301
}
302302

303303
/// Sets the value of the `application_name` runtime parameter.
304-
pubfnapplication_name(&mutself,application_name:&str) ->&mutConfig{
305-
self.application_name =Some(application_name.to_string());
304+
pubfnapplication_name(&mutself,application_name:implInto<String>) ->&mutConfig{
305+
self.application_name =Some(application_name.into());
306306
self
307307
}
308308

@@ -330,15 +330,17 @@ impl Config {
330330
/// Multiple hosts can be specified by calling this method multiple times, and each will be tried in order. On Unix
331331
/// systems, a host starting with a `/` is interpreted as a path to a directory containing Unix domain sockets.
332332
/// There must be either no hosts, or the same number of hosts as hostaddrs.
333-
pubfnhost(&mutself,host:&str) ->&mutConfig{
333+
pubfnhost(&mutself,host:implInto<String>) ->&mutConfig{
334+
let host = host.into();
335+
334336
#[cfg(unix)]
335337
{
336338
if host.starts_with('/'){
337339
returnself.host_path(host);
338340
}
339341
}
340342

341-
self.host.push(Host::Tcp(host.to_string()));
343+
self.host.push(Host::Tcp(host));
342344
self
343345
}
344346

@@ -990,7 +992,7 @@ impl<'a> UrlParser<'a> {
990992

991993
letmut it = creds.splitn(2,':');
992994
let user =self.decode(it.next().unwrap())?;
993-
self.config.user(&user);
995+
self.config.user(user);
994996

995997
ifletSome(password) = it.next(){
996998
let password =Cow::from(percent_encoding::percent_decode(password.as_bytes()));
@@ -1053,7 +1055,7 @@ impl<'a> UrlParser<'a> {
10531055
};
10541056

10551057
if !dbname.is_empty(){
1056-
self.config.dbname(&self.decode(dbname)?);
1058+
self.config.dbname(self.decode(dbname)?);
10571059
}
10581060

10591061
Ok(())

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp