Skip to content

Commit 016e9a3

Browse files
committed
avoid a silly clone
1 parent b411e5c commit 016e9a3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tokio-postgres/src/connect_raw.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use postgres_protocol::authentication::sasl;
1313
use postgres_protocol::authentication::sasl::ScramSha256;
1414
use postgres_protocol::message::backend::{AuthenticationSaslBody, Message};
1515
use postgres_protocol::message::frontend;
16+
use std::borrow::Cow;
1617
use std::collections::{HashMap, VecDeque};
1718
use std::io;
1819
use std::pin::Pin;
@@ -96,7 +97,10 @@ where
9697
delayed: VecDeque::new(),
9798
};
9899

99-
let user = config.user.clone().unwrap_or_else(whoami::username);
100+
let user = config
101+
.user
102+
.as_deref()
103+
.map_or_else(|| Cow::Owned(whoami::username()), Cow::Borrowed);
100104

101105
startup(&mut stream, config, &user).await?;
102106
authenticate(&mut stream, config, &user).await?;

0 commit comments

Comments
 (0)