@@ -184,9 +184,7 @@ impl<'conn > Iterator<PostgresNotification> for
184184 /// `next` may return `Some` notification after returning `None` if a new
185185 /// notification was received.
186186 fn next ( & mut self ) -> Option < PostgresNotification > {
187- do self . conn . conn . with_mut |conn| {
188- conn. notifications . pop_front ( )
189- }
187+ self . conn . conn . with_mut ( |conn| { conn. notifications . pop_front ( ) } )
190188 }
191189}
192190
@@ -235,18 +233,18 @@ pub fn cancel_query(url: &str, ssl: &SslMode, data: PostgresCancelData)
235233
236234fn open_socket ( host : & str , port : Port )
237235 -> Result < TcpStream , PostgresConnectError > {
238- let addrs = do io_error:: cond. trap ( |_| { } ) . inside {
236+ let addrs = io_error:: cond. trap ( |_| { } ) . inside ( || {
239237 net:: get_host_addresses ( host)
240- } ;
238+ } ) ;
241239 let addrs = match addrs {
242240 Some ( addrs) => addrs,
243241 None => return Err ( DnsError )
244242 } ;
245243
246244 for addr in addrs. iter ( ) {
247- let socket = do io_error:: cond. trap ( |_| { } ) . inside {
245+ let socket = io_error:: cond. trap ( |_| { } ) . inside ( || {
248246 TcpStream :: connect ( SocketAddr { ip : * addr, port : port } )
249- } ;
247+ } ) ;
250248 match socket {
251249 Some ( socket) => return Ok ( socket) ,
252250 None => { }
@@ -326,9 +324,9 @@ struct InnerPostgresConnection {
326324
327325impl Drop for InnerPostgresConnection {
328326 fn drop ( & mut self ) {
329- do io_error:: cond. trap ( |_| { } ) . inside {
327+ io_error:: cond. trap ( |_| { } ) . inside ( || {
330328 self . write_messages ( [ Terminate ] ) ;
331- }
329+ } )
332330 }
333331}
334332
@@ -566,11 +564,11 @@ impl PostgresConnection {
566564 /// username if not specified.
567565 pub fn try_connect ( url : & str , ssl : & SslMode )
568566 -> Result < PostgresConnection , PostgresConnectError > {
569- do InnerPostgresConnection :: try_connect ( url, ssl) . map |conn| {
567+ InnerPostgresConnection :: try_connect ( url, ssl) . map ( |conn| {
570568 PostgresConnection {
571569 conn : RefCell :: new ( conn)
572570 }
573- }
571+ } )
574572 }
575573
576574 /// A convenience wrapper around `try_connect`.
@@ -611,9 +609,7 @@ impl PostgresConnection {
611609 /// not outlive that connection.
612610 pub fn try_prepare < ' a > ( & ' a self , query : & str )
613611 -> Result < NormalPostgresStatement < ' a > , PostgresDbError > {
614- do self . conn . with_mut |conn| {
615- conn. try_prepare ( query, self )
616- }
612+ self . conn . with_mut ( |conn| conn. try_prepare ( query, self ) )
617613 }
618614
619615 /// A convenience wrapper around `try_prepare`.
@@ -653,9 +649,7 @@ impl PostgresConnection {
653649 /// On success, returns the number of rows modified or 0 if not applicable.
654650 pub fn try_update ( & self , query : & str , params : & [ & ToSql ] )
655651 -> Result < uint , PostgresDbError > {
656- do self . try_prepare ( query) . and_then |stmt| {
657- stmt. try_update ( params)
658- }
652+ self . try_prepare ( query) . and_then ( |stmt| stmt. try_update ( params) )
659653 }
660654
661655 /// A convenience wrapper around `try_update`.
@@ -676,13 +670,11 @@ impl PostgresConnection {
676670 /// Used with the `cancel_query` function. The object returned can be used
677671 /// to cancel any query executed by the connection it was created from.
678672 pub fn cancel_data ( & self ) -> PostgresCancelData {
679- do self . conn . with |conn| {
680- conn. cancel_data
681- }
673+ self . conn . with ( |conn| conn. cancel_data )
682674 }
683675
684676 fn quick_query ( & self , query : & str ) {
685- do self . conn . with_mut |conn| {
677+ self . conn . with_mut ( |conn| {
686678 conn. write_messages ( [ Query { query : query } ] ) ;
687679
688680 loop {
@@ -694,25 +686,19 @@ impl PostgresConnection {
694686 _ => { }
695687 }
696688 }
697- }
689+ } )
698690 }
699691
700692 fn wait_for_ready ( & self ) {
701- do self . conn . with_mut |conn| {
702- conn. wait_for_ready ( )
703- }
693+ self . conn . with_mut ( |conn| conn. wait_for_ready ( ) )
704694 }
705695
706696 fn read_message ( & self ) -> BackendMessage {
707- do self . conn . with_mut |conn| {
708- conn. read_message ( )
709- }
697+ self . conn . with_mut ( |conn| conn. read_message ( ) )
710698 }
711699
712700 fn write_messages ( & self , messages : & [ FrontendMessage ] ) {
713- do self . conn . with_mut |conn| {
714- conn. write_messages ( messages)
715- }
701+ self . conn . with_mut ( |conn| conn. write_messages ( messages) )
716702 }
717703}
718704
@@ -736,7 +722,7 @@ pub struct PostgresTransaction<'conn> {
736722#[ unsafe_destructor]
737723impl < ' conn > Drop for PostgresTransaction < ' conn > {
738724 fn drop ( & mut self ) {
739- do io_error:: cond. trap ( |_| { } ) . inside {
725+ io_error:: cond. trap ( |_| { } ) . inside ( || {
740726 if task:: failing ( ) || !self . commit . with ( |x| * x) {
741727 if self . nested {
742728 self . conn . quick_query ( "ROLLBACK TO sp" ) ;
@@ -750,19 +736,19 @@ impl<'conn> Drop for PostgresTransaction<'conn> {
750736 self . conn . quick_query ( "COMMIT" ) ;
751737 }
752738 }
753- }
739+ } )
754740 }
755741}
756742
757743impl < ' conn > PostgresTransaction < ' conn > {
758744 /// Like `PostgresConnection::try_prepare`.
759745 pub fn try_prepare < ' a > ( & ' a self , query : & str )
760746 -> Result < TransactionalPostgresStatement < ' a > , PostgresDbError > {
761- do self . conn . try_prepare ( query) . map |stmt| {
747+ self . conn . try_prepare ( query) . map ( |stmt| {
762748 TransactionalPostgresStatement {
763749 stmt : stmt
764750 }
765- }
751+ } )
766752 }
767753
768754 /// Like `PostgresConnection::prepare`.
@@ -881,7 +867,7 @@ pub struct NormalPostgresStatement<'conn> {
881867#[ unsafe_destructor]
882868impl < ' conn > Drop for NormalPostgresStatement < ' conn > {
883869 fn drop ( & mut self ) {
884- do io_error:: cond. trap ( |_| { } ) . inside {
870+ io_error:: cond. trap ( |_| { } ) . inside ( || {
885871 self . conn . write_messages ( [
886872 Close {
887873 variant : 'S' as u8 ,
@@ -894,7 +880,7 @@ impl<'conn> Drop for NormalPostgresStatement<'conn> {
894880 _ => { }
895881 }
896882 }
897- }
883+ } )
898884 }
899885}
900886
@@ -992,7 +978,7 @@ impl<'conn> PostgresStatement for NormalPostgresStatement<'conn> {
992978 return Err ( PostgresDbError :: new ( fields) ) ;
993979 }
994980 CommandComplete { tag } => {
995- let s = tag. split_iter ( ' ' ) . last ( ) . unwrap ( ) ;
981+ let s = tag. split ( ' ' ) . last ( ) . unwrap ( ) ;
996982 num = match FromStr :: from_str ( s) {
997983 None => 0 ,
998984 Some ( n) => n
@@ -1107,7 +1093,7 @@ pub struct PostgresResult<'stmt> {
11071093#[ unsafe_destructor]
11081094impl < ' stmt > Drop for PostgresResult < ' stmt > {
11091095 fn drop ( & mut self ) {
1110- do io_error:: cond. trap ( |_| { } ) . inside {
1096+ io_error:: cond. trap ( |_| { } ) . inside ( || {
11111097 self . stmt . conn . write_messages ( [
11121098 Close {
11131099 variant : 'P' as u8 ,
@@ -1120,7 +1106,7 @@ impl<'stmt> Drop for PostgresResult<'stmt> {
11201106 _ => { }
11211107 }
11221108 }
1123- }
1109+ } )
11241110 }
11251111}
11261112
@@ -1161,12 +1147,12 @@ impl<'stmt> Iterator<PostgresRow<'stmt>> for PostgresResult<'stmt> {
11611147 self . execute ( ) ;
11621148 }
11631149
1164- do self. data . pop_front ( ) . map |row| {
1150+ self . data . pop_front ( ) . map ( |row| {
11651151 PostgresRow {
11661152 stmt : self . stmt ,
11671153 data : row
11681154 }
1169- }
1155+ } )
11701156 }
11711157}
11721158
0 commit comments