@@ -64,7 +64,7 @@ extern crate phf_mac;
6464#[ phase( plugin, link) ]
6565extern crate log;
6666
67- use collections:: { Deque , RingBuf } ;
67+ use collections:: RingBuf ;
6868use url:: Url ;
6969use openssl:: crypto:: hash:: { MD5 , Hasher } ;
7070use openssl:: ssl:: SslContext ;
@@ -181,17 +181,15 @@ pub struct ConnectParams {
181181 pub port : Option < Port > ,
182182 /// The user to login as.
183183 ///
184- /// `Connection::connect` requires a user but `cancel_query` does
185- /// not.
184+ /// `Connection::connect` requires a user but `cancel_query` does not.
186185 pub user : Option < UserInfo > ,
187186 /// The database to connect to. Defaults the value of `user`.
188187 pub database : Option < String > ,
189188 /// Runtime parameters to be passed to the Postgres backend.
190189 pub options : Vec < ( String , String ) > ,
191190}
192191
193- /// A trait implemented by types that can be converted into a
194- /// `ConnectParams`.
192+ /// A trait implemented by types that can be converted into a `ConnectParams`.
195193pub trait IntoConnectParams {
196194 /// Converts the value of `self` into a `ConnectParams`.
197195 fn into_connect_params ( self ) -> result:: Result < ConnectParams , PostgresConnectError > ;
@@ -229,10 +227,9 @@ impl IntoConnectParams for Url {
229227 TargetTcp ( host)
230228 } ;
231229
232- let user = match user {
233- Some ( url:: UserInfo { user, pass } ) => Some ( UserInfo { user : user, password : pass } ) ,
234- None => None ,
235- } ;
230+ let user = user. map ( |url:: UserInfo { user, pass } | {
231+ UserInfo { user : user, password : pass }
232+ } ) ;
236233
237234 let database = if !path. is_empty ( ) {
238235 // path contains the leading /
@@ -506,8 +503,7 @@ impl InnerConnection {
506503 }
507504 }
508505
509- fn set_notice_handler ( & mut self , handler : Box < NoticeHandler +Send > )
510- -> Box < NoticeHandler +Send > {
506+ fn set_notice_handler ( & mut self , handler : Box < NoticeHandler +Send > ) -> Box < NoticeHandler +Send > {
511507 mem:: replace ( & mut self . notice_handler , handler)
512508 }
513509
0 commit comments