@@ -181,13 +181,8 @@ impl IntoConnectParams for Url {
181
181
UserInfo { user : user, password : pass }
182
182
} ) ;
183
183
184
- let database = if !path. is_empty ( ) {
185
- // path contains the leading /
186
- let ( _, path) = path[ ] . slice_shift_char ( ) ;
187
- Some ( path. into_string ( ) )
188
- } else {
189
- Option :: None
190
- } ;
184
+ // path contains the leading /
185
+ let database = path. slice_shift_char ( ) . map ( |( _, path) | path. into_string ( ) ) ;
191
186
192
187
Ok ( ConnectParams {
193
188
target : target,
@@ -271,7 +266,7 @@ pub struct CancelData {
271
266
/// let conn = Connection::connect(url, &SslMode::None).unwrap();
272
267
/// let cancel_data = conn.cancel_data();
273
268
/// spawn(proc() {
274
- /// conn.execute("SOME EXPENSIVE QUERY", []).unwrap();
269
+ /// conn.execute("SOME EXPENSIVE QUERY", & []).unwrap();
275
270
/// });
276
271
/// # let _ =
277
272
/// postgres::cancel_query(url, &SslMode::None, cancel_data);
@@ -351,7 +346,7 @@ impl InnerConnection {
351
346
Option :: None => { }
352
347
}
353
348
354
- try!( conn. write_messages ( [ StartupMessage {
349
+ try!( conn. write_messages ( & [ StartupMessage {
355
350
version : message:: PROTOCOL_VERSION ,
356
351
parameters : options[ ]
357
352
} ] ) ) ;
@@ -410,7 +405,7 @@ impl InnerConnection {
410
405
AuthenticationOk => return Ok ( ( ) ) ,
411
406
AuthenticationCleartextPassword => {
412
407
let pass = try!( user. password . ok_or ( ConnectError :: MissingPassword ) ) ;
413
- try!( self . write_messages ( [ PasswordMessage {
408
+ try!( self . write_messages ( & [ PasswordMessage {
414
409
password : pass[ ] ,
415
410
} ] ) ) ;
416
411
}
@@ -422,9 +417,9 @@ impl InnerConnection {
422
417
let output = hasher. finalize ( ) [ ] . to_hex ( ) ;
423
418
let hasher = Hasher :: new ( MD5 ) ;
424
419
hasher. update ( output. as_bytes ( ) ) ;
425
- hasher. update ( salt) ;
420
+ hasher. update ( & salt) ;
426
421
let output = format ! ( "md5{}" , hasher. finalize( ) [ ] . to_hex( ) ) ;
427
- try!( self . write_messages ( [ PasswordMessage {
422
+ try!( self . write_messages ( & [ PasswordMessage {
428
423
password : output[ ]
429
424
} ] ) ) ;
430
425
}
@@ -458,11 +453,11 @@ impl InnerConnection {
458
453
let stmt_name = format ! ( "s{}" , self . next_stmt_id) ;
459
454
self . next_stmt_id += 1 ;
460
455
461
- try!( self . write_messages ( [
456
+ try!( self . write_messages ( & [
462
457
Parse {
463
458
name : stmt_name[ ] ,
464
459
query : query,
465
- param_types : [ ]
460
+ param_types : & [ ]
466
461
} ,
467
462
Describe {
468
463
variant : b'S' ,
@@ -548,7 +543,7 @@ impl InnerConnection {
548
543
}
549
544
550
545
fn close_statement ( & mut self , stmt_name : & str ) -> Result < ( ) > {
551
- try!( self . write_messages ( [
546
+ try!( self . write_messages ( & [
552
547
Close {
553
548
variant : b'S' ,
554
549
name : stmt_name,
@@ -605,7 +600,7 @@ impl InnerConnection {
605
600
606
601
fn quick_query ( & mut self , query : & str ) -> Result < Vec < Vec < Option < String > > > > {
607
602
check_desync ! ( self ) ;
608
- try!( self . write_messages ( [ Query { query : query } ] ) ) ;
603
+ try!( self . write_messages ( & [ Query { query : query } ] ) ) ;
609
604
610
605
let mut result = vec ! [ ] ;
611
606
loop {
@@ -617,7 +612,7 @@ impl InnerConnection {
617
612
} ) . collect ( ) ) ;
618
613
}
619
614
CopyInResponse { .. } => {
620
- try!( self . write_messages ( [
615
+ try!( self . write_messages ( & [
621
616
CopyFail {
622
617
message : "COPY queries cannot be directly executed" ,
623
618
} ,
@@ -636,7 +631,7 @@ impl InnerConnection {
636
631
fn finish_inner ( & mut self ) -> Result < ( ) > {
637
632
check_desync ! ( self ) ;
638
633
self . canary = 0 ;
639
- try!( self . write_messages ( [ Terminate ] ) ) ;
634
+ try!( self . write_messages ( & [ Terminate ] ) ) ;
640
635
Ok ( ( ) )
641
636
}
642
637
}
@@ -762,9 +757,9 @@ impl Connection {
762
757
/// try!(conn.execute("CREATE TABLE foo (
763
758
/// bar INT PRIMARY KEY,
764
759
/// baz VARCHAR
765
- /// )", []));
760
+ /// )", & []));
766
761
///
767
- /// let stmt = try!(conn.prepare_copy_in("foo", ["bar", "baz"]));
762
+ /// let stmt = try!(conn.prepare_copy_in("foo", & ["bar", "baz"]));
768
763
/// let data: &[&[&ToSql]] = &[&[&0i32, &"blah".into_string()],
769
764
/// &[&1i32, &None::<String>]];
770
765
/// try!(stmt.execute(data.iter().map(|r| r.iter().map(|&e| e))));
@@ -796,7 +791,7 @@ impl Connection {
796
791
/// # fn foo() -> Result<(), postgres::Error> {
797
792
/// # let conn = Connection::connect("", &SslMode::None).unwrap();
798
793
/// let trans = try!(conn.transaction());
799
- /// try!(trans.execute("UPDATE foo SET bar = 10", []));
794
+ /// try!(trans.execute("UPDATE foo SET bar = 10", & []));
800
795
/// // ...
801
796
///
802
797
/// try!(trans.commit());
@@ -1095,13 +1090,13 @@ impl<'conn> Statement<'conn> {
1095
1090
values. push ( try!( param. to_sql ( ty) ) ) ;
1096
1091
} ;
1097
1092
1098
- try!( conn. write_messages ( [
1093
+ try!( conn. write_messages ( & [
1099
1094
Bind {
1100
1095
portal : portal_name,
1101
1096
statement : self . name [ ] ,
1102
- formats : [ 1 ] ,
1097
+ formats : & [ 1 ] ,
1103
1098
values : values[ ] ,
1104
- result_formats : [ 1 ]
1099
+ result_formats : & [ 1 ]
1105
1100
} ,
1106
1101
Execute {
1107
1102
portal : portal_name,
@@ -1190,7 +1185,7 @@ impl<'conn> Statement<'conn> {
1190
1185
break ;
1191
1186
}
1192
1187
CopyInResponse { .. } => {
1193
- try!( conn. write_messages ( [
1188
+ try!( conn. write_messages ( & [
1194
1189
CopyFail {
1195
1190
message : "COPY queries cannot be directly executed" ,
1196
1191
} ,
@@ -1273,7 +1268,7 @@ impl<'stmt> Rows<'stmt> {
1273
1268
fn finish_inner ( & mut self ) -> Result < ( ) > {
1274
1269
let mut conn = self . stmt . conn . conn . borrow_mut ( ) ;
1275
1270
check_desync ! ( conn) ;
1276
- try!( conn. write_messages ( [
1271
+ try!( conn. write_messages ( & [
1277
1272
Close {
1278
1273
variant : b'P' ,
1279
1274
name : self . name [ ]
@@ -1312,7 +1307,7 @@ impl<'stmt> Rows<'stmt> {
1312
1307
return DbError :: new ( fields) ;
1313
1308
}
1314
1309
CopyInResponse { .. } => {
1315
- try!( conn. write_messages ( [
1310
+ try!( conn. write_messages ( & [
1316
1311
CopyFail {
1317
1312
message : "COPY queries cannot be directly executed" ,
1318
1313
} ,
@@ -1328,7 +1323,7 @@ impl<'stmt> Rows<'stmt> {
1328
1323
}
1329
1324
1330
1325
fn execute ( & mut self ) -> Result < ( ) > {
1331
- try!( self . stmt . conn . write_messages ( [
1326
+ try!( self . stmt . conn . write_messages ( & [
1332
1327
Execute {
1333
1328
portal : self . name [ ] ,
1334
1329
max_rows : self . row_limit
@@ -1417,7 +1412,7 @@ impl<'stmt> Row<'stmt> {
1417
1412
/// # use postgres::{Connection, SslMode};
1418
1413
/// # let conn = Connection::connect("", &SslMode::None).unwrap();
1419
1414
/// # let stmt = conn.prepare("").unwrap();
1420
- /// # let mut result = stmt.query([]).unwrap();
1415
+ /// # let mut result = stmt.query(& []).unwrap();
1421
1416
/// # let row = result.next().unwrap();
1422
1417
/// let foo: i32 = row.get(0u);
1423
1418
/// let bar: String = row.get("bar");
@@ -1520,13 +1515,13 @@ impl<'a> CopyInStatement<'a> {
1520
1515
where I : Iterator < J > , J : Iterator < & ' b ToSql + ' b > {
1521
1516
let mut conn = self . conn . conn . borrow_mut ( ) ;
1522
1517
1523
- try!( conn. write_messages ( [
1518
+ try!( conn. write_messages ( & [
1524
1519
Bind {
1525
1520
portal : "" ,
1526
1521
statement : self . name [ ] ,
1527
- formats : [ ] ,
1528
- values : [ ] ,
1529
- result_formats : [ ]
1522
+ formats : & [ ] ,
1523
+ values : & [ ] ,
1524
+ result_formats : & [ ]
1530
1525
} ,
1531
1526
Execute {
1532
1527
portal : "" ,
@@ -1605,7 +1600,7 @@ impl<'a> CopyInStatement<'a> {
1605
1600
}
1606
1601
1607
1602
let _ = buf. write_be_i16 ( -1 ) ;
1608
- try!( conn. write_messages ( [
1603
+ try!( conn. write_messages ( & [
1609
1604
CopyData {
1610
1605
data : buf. unwrap ( ) [ ] ,
1611
1606
} ,
0 commit comments