Skip to content

Commit

Permalink
feat(postgres): make the options taking parameters with Display trait
Browse files Browse the repository at this point in the history
  • Loading branch information
liushuyu committed Dec 29, 2021
1 parent 28462fd commit 47acea7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions sqlx-core/src/postgres/options/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::env::var;
use std::fmt::Display;
use std::path::{Path, PathBuf};

mod connect;
Expand Down Expand Up @@ -322,7 +323,7 @@ impl PgConnectOptions {
self
}

/// Sets the extra options. Defaults to None
/// Set additional startup options for the connection as a list of key-value pairs.
///
/// # Example
///
Expand All @@ -333,13 +334,13 @@ impl PgConnectOptions {
/// ```
pub fn options<K, V, I>(mut self, options: I) -> Self
where
K: ToString,
V: ToString,
K: Display,
V: Display,
I: IntoIterator<Item = (K, V)>,
{
let mut options_str = String::new();
for (k, v) in options {
options_str += &format!("-c {}={}", k.to_string(), v.to_string());
options_str += &format!("-c {}={}", k, v);
}
if let Some(ref mut v) = self.options {
v.push(' ');
Expand Down

0 comments on commit 47acea7

Please sign in to comment.