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

Avoid extra clone in config if possible#1137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
sfackler merged 1 commit intorust-postgres:masterfromnyurik:use-string
Jul 6, 2024
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletionstokio-postgres/src/config.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -248,8 +248,8 @@ impl Config {
/// Sets the user to authenticate with.
///
/// Defaults to the user executing this process.
pub fn user(&mut self, user:&str) -> &mut Config {
self.user = Some(user.to_string());
pub fn user(&mut self, user:impl Into<String>) -> &mut Config {
self.user = Some(user.into());
self
}

Expand DownExpand Up@@ -277,8 +277,8 @@ impl Config {
/// Sets the name of the database to connect to.
///
/// Defaults to the user.
pub fn dbname(&mut self, dbname:&str) -> &mut Config {
self.dbname = Some(dbname.to_string());
pub fn dbname(&mut self, dbname:impl Into<String>) -> &mut Config {
self.dbname = Some(dbname.into());
self
}

Expand All@@ -289,8 +289,8 @@ impl Config {
}

/// Sets command line options used to configure the server.
pub fn options(&mut self, options:&str) -> &mut Config {
self.options = Some(options.to_string());
pub fn options(&mut self, options:impl Into<String>) -> &mut Config {
self.options = Some(options.into());
self
}

Expand All@@ -301,8 +301,8 @@ impl Config {
}

/// Sets the value of the `application_name` runtime parameter.
pub fn application_name(&mut self, application_name:&str) -> &mut Config {
self.application_name = Some(application_name.to_string());
pub fn application_name(&mut self, application_name:impl Into<String>) -> &mut Config {
self.application_name = Some(application_name.into());
self
}

Expand DownExpand Up@@ -330,15 +330,17 @@ impl Config {
/// Multiple hosts can be specified by calling this method multiple times, and each will be tried in order. On Unix
/// systems, a host starting with a `/` is interpreted as a path to a directory containing Unix domain sockets.
/// There must be either no hosts, or the same number of hosts as hostaddrs.
pub fn host(&mut self, host: &str) -> &mut Config {
pub fn host(&mut self, host: impl Into<String>) -> &mut Config {
let host = host.into();

#[cfg(unix)]
{
if host.starts_with('/') {
return self.host_path(host);
}
}

self.host.push(Host::Tcp(host.to_string()));
self.host.push(Host::Tcp(host));
self
}

Expand DownExpand Up@@ -990,7 +992,7 @@ impl<'a> UrlParser<'a> {

let mut it = creds.splitn(2, ':');
let user = self.decode(it.next().unwrap())?;
self.config.user(&user);
self.config.user(user);

if let Some(password) = it.next() {
let password = Cow::from(percent_encoding::percent_decode(password.as_bytes()));
Expand DownExpand Up@@ -1053,7 +1055,7 @@ impl<'a> UrlParser<'a> {
};

if !dbname.is_empty() {
self.config.dbname(&self.decode(dbname)?);
self.config.dbname(self.decode(dbname)?);
}

Ok(())
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp