Skip to content

Commit 0aac822

Browse files
committed
Impl IntoConnectParams for Url
1 parent b9efef8 commit 0aac822

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

src/lib.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,16 @@ impl IntoConnectParams for PostgresConnectParams {
248248
}
249249

250250
impl<'a> IntoConnectParams for &'a str {
251+
fn into_connect_params(self) -> Result<PostgresConnectParams,
252+
PostgresConnectError> {
253+
match url::from_str(self) {
254+
Ok(url) => url.into_connect_params(),
255+
Err(err) => return Err(InvalidUrl(err)),
256+
}
257+
}
258+
}
259+
260+
impl IntoConnectParams for Url {
251261
fn into_connect_params(self) -> Result<PostgresConnectParams,
252262
PostgresConnectError> {
253263
let Url {
@@ -257,10 +267,7 @@ impl<'a> IntoConnectParams for &'a str {
257267
path,
258268
query: options,
259269
..
260-
} = match url::from_str(self) {
261-
Ok(url) => url,
262-
Err(err) => return Err(InvalidUrl(err))
263-
};
270+
} = self;
264271

265272
let maybe_path = url::decode_component(host.as_slice());
266273
let target = if maybe_path.as_slice().starts_with("/") {

0 commit comments

Comments
 (0)