Merge pull request #657 from botika/master
Clean code at connect function
This commit is contained in:
commit
cd31c02d77
@ -25,14 +25,15 @@ where
|
|||||||
|
|
||||||
let mut error = None;
|
let mut error = None;
|
||||||
for (i, host) in config.host.iter().enumerate() {
|
for (i, host) in config.host.iter().enumerate() {
|
||||||
let port = *config
|
let port = config
|
||||||
.port
|
.port
|
||||||
.get(i)
|
.get(i)
|
||||||
.or_else(|| config.port.get(0))
|
.or_else(|| config.port.get(0))
|
||||||
.unwrap_or(&5432);
|
.copied()
|
||||||
|
.unwrap_or(5432);
|
||||||
|
|
||||||
let hostname = match host {
|
let hostname = match host {
|
||||||
Host::Tcp(host) => &**host,
|
Host::Tcp(host) => host.as_str(),
|
||||||
// postgres doesn't support TLS over unix sockets, so the choice here doesn't matter
|
// postgres doesn't support TLS over unix sockets, so the choice here doesn't matter
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
Host::Unix(_) => "",
|
Host::Unix(_) => "",
|
||||||
|
Loading…
Reference in New Issue
Block a user