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

Commitd85beda

Browse files
committed
Fix for upstream changes
1 parentb77d616 commitd85beda

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

‎src/lib.rs‎

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::fmt;
1010
use postgres::{IntoConnectParams,SslMode};
1111

1212
/// A unified enum of errors returned by postgres::Connection
13-
#[derive(Clone,Debug)]
13+
#[derive(Debug)]
1414
pubenumError{
1515
/// A postgres::ConnectError
1616
Connect(postgres::ConnectError),
@@ -59,7 +59,7 @@ impl error::Error for Error {
5959
/// fn main() {
6060
/// let config = Default::default();
6161
/// let manager = PostgresConnectionManager::new("postgres://postgres@localhost",
62-
/// SslMode::None);
62+
/// SslMode::None).unwrap();
6363
/// let error_handler = Box::new(r2d2::LoggingErrorHandler);
6464
/// let pool = Arc::new(r2d2::Pool::new(config, manager, error_handler).unwrap());
6565
///
@@ -73,7 +73,7 @@ impl error::Error for Error {
7373
/// }
7474
/// ```
7575
pubstructPostgresConnectionManager{
76-
params:Result<postgres::ConnectParams, postgres::ConnectError>,
76+
params: postgres::ConnectParams,
7777
ssl_mode:SslMode,
7878
}
7979

@@ -89,11 +89,12 @@ impl PostgresConnectionManager {
8989
///
9090
/// See `postgres::Connection::connect` for a description of the parameter
9191
/// types.
92-
pubfnnew<T:IntoConnectParams>(params:T,ssl_mode:SslMode) ->PostgresConnectionManager{
93-
PostgresConnectionManager{
94-
params: params.into_connect_params(),
92+
pubfnnew<T:IntoConnectParams>(params:T,ssl_mode:SslMode)
93+
->Result<PostgresConnectionManager, postgres::ConnectError>{
94+
Ok(PostgresConnectionManager{
95+
params: try!(params.into_connect_params()),
9596
ssl_mode: ssl_mode,
96-
}
97+
})
9798
}
9899
}
99100

@@ -102,12 +103,7 @@ impl r2d2::ConnectionManager for PostgresConnectionManager {
102103
typeError =Error;
103104

104105
fnconnect(&self) ->Result<postgres::Connection,Error>{
105-
matchself.params{
106-
Ok(ref p) =>{
107-
postgres::Connection::connect(p.clone(),&self.ssl_mode).map_err(Error::Connect)
108-
}
109-
Err(ref e) =>Err(Error::Connect(e.clone()))
110-
}
106+
postgres::Connection::connect(self.params.clone(),&self.ssl_mode).map_err(Error::Connect)
111107
}
112108

113109
fnis_valid(&self,conn:&mut postgres::Connection) ->Result<(),Error>{

‎tests/test.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use r2d2_postgres::PostgresConnectionManager;
1111

1212
#[test]
1313
fntest_basic(){
14-
let manager =PostgresConnectionManager::new("postgres://postgres@localhost",SslMode::None);
14+
let manager =PostgresConnectionManager::new("postgres://postgres@localhost",SslMode::None).unwrap();
1515
let config = r2d2::Config::builder().pool_size(2).build();
1616
let handler =Box::new(r2d2::NoopErrorHandler);
1717
let pool =Arc::new(r2d2::Pool::new(config, manager, handler).unwrap());
@@ -43,7 +43,7 @@ fn test_basic() {
4343

4444
#[test]
4545
fntest_is_valid(){
46-
let manager =PostgresConnectionManager::new("postgres://postgres@localhost",SslMode::None);
46+
let manager =PostgresConnectionManager::new("postgres://postgres@localhost",SslMode::None).unwrap();
4747
let config = r2d2::Config::builder().pool_size(1).test_on_check_out(true).build();
4848
let handler =Box::new(r2d2::NoopErrorHandler);
4949
let pool = r2d2::Pool::new(config, manager, handler).unwrap();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp