Skip to content

Commit 3a0f189

Browse files
committed
Merge pull request #80 from Ryman/master
Fixes for nightly
2 parents a6f0edb + 465bb9e commit 3a0f189

File tree

7 files changed

+129
-134
lines changed

7 files changed

+129
-134
lines changed

src/lib.rs

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,8 @@ impl IntoConnectParams for Url {
181181
UserInfo { user: user, password: pass }
182182
});
183183

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());
191186

192187
Ok(ConnectParams {
193188
target: target,
@@ -271,7 +266,7 @@ pub struct CancelData {
271266
/// let conn = Connection::connect(url, &SslMode::None).unwrap();
272267
/// let cancel_data = conn.cancel_data();
273268
/// spawn(proc() {
274-
/// conn.execute("SOME EXPENSIVE QUERY", []).unwrap();
269+
/// conn.execute("SOME EXPENSIVE QUERY", &[]).unwrap();
275270
/// });
276271
/// # let _ =
277272
/// postgres::cancel_query(url, &SslMode::None, cancel_data);
@@ -351,7 +346,7 @@ impl InnerConnection {
351346
Option::None => {}
352347
}
353348

354-
try!(conn.write_messages([StartupMessage {
349+
try!(conn.write_messages(&[StartupMessage {
355350
version: message::PROTOCOL_VERSION,
356351
parameters: options[]
357352
}]));
@@ -410,7 +405,7 @@ impl InnerConnection {
410405
AuthenticationOk => return Ok(()),
411406
AuthenticationCleartextPassword => {
412407
let pass = try!(user.password.ok_or(ConnectError::MissingPassword));
413-
try!(self.write_messages([PasswordMessage {
408+
try!(self.write_messages(&[PasswordMessage {
414409
password: pass[],
415410
}]));
416411
}
@@ -422,9 +417,9 @@ impl InnerConnection {
422417
let output = hasher.finalize()[].to_hex();
423418
let hasher = Hasher::new(MD5);
424419
hasher.update(output.as_bytes());
425-
hasher.update(salt);
420+
hasher.update(&salt);
426421
let output = format!("md5{}", hasher.finalize()[].to_hex());
427-
try!(self.write_messages([PasswordMessage {
422+
try!(self.write_messages(&[PasswordMessage {
428423
password: output[]
429424
}]));
430425
}
@@ -458,11 +453,11 @@ impl InnerConnection {
458453
let stmt_name = format!("s{}", self.next_stmt_id);
459454
self.next_stmt_id += 1;
460455

461-
try!(self.write_messages([
456+
try!(self.write_messages(&[
462457
Parse {
463458
name: stmt_name[],
464459
query: query,
465-
param_types: []
460+
param_types: &[]
466461
},
467462
Describe {
468463
variant: b'S',
@@ -548,7 +543,7 @@ impl InnerConnection {
548543
}
549544

550545
fn close_statement(&mut self, stmt_name: &str) -> Result<()> {
551-
try!(self.write_messages([
546+
try!(self.write_messages(&[
552547
Close {
553548
variant: b'S',
554549
name: stmt_name,
@@ -605,7 +600,7 @@ impl InnerConnection {
605600

606601
fn quick_query(&mut self, query: &str) -> Result<Vec<Vec<Option<String>>>> {
607602
check_desync!(self);
608-
try!(self.write_messages([Query { query: query }]));
603+
try!(self.write_messages(&[Query { query: query }]));
609604

610605
let mut result = vec![];
611606
loop {
@@ -617,7 +612,7 @@ impl InnerConnection {
617612
}).collect());
618613
}
619614
CopyInResponse { .. } => {
620-
try!(self.write_messages([
615+
try!(self.write_messages(&[
621616
CopyFail {
622617
message: "COPY queries cannot be directly executed",
623618
},
@@ -636,7 +631,7 @@ impl InnerConnection {
636631
fn finish_inner(&mut self) -> Result<()> {
637632
check_desync!(self);
638633
self.canary = 0;
639-
try!(self.write_messages([Terminate]));
634+
try!(self.write_messages(&[Terminate]));
640635
Ok(())
641636
}
642637
}
@@ -762,9 +757,9 @@ impl Connection {
762757
/// try!(conn.execute("CREATE TABLE foo (
763758
/// bar INT PRIMARY KEY,
764759
/// baz VARCHAR
765-
/// )", []));
760+
/// )", &[]));
766761
///
767-
/// let stmt = try!(conn.prepare_copy_in("foo", ["bar", "baz"]));
762+
/// let stmt = try!(conn.prepare_copy_in("foo", &["bar", "baz"]));
768763
/// let data: &[&[&ToSql]] = &[&[&0i32, &"blah".into_string()],
769764
/// &[&1i32, &None::<String>]];
770765
/// try!(stmt.execute(data.iter().map(|r| r.iter().map(|&e| e))));
@@ -796,7 +791,7 @@ impl Connection {
796791
/// # fn foo() -> Result<(), postgres::Error> {
797792
/// # let conn = Connection::connect("", &SslMode::None).unwrap();
798793
/// let trans = try!(conn.transaction());
799-
/// try!(trans.execute("UPDATE foo SET bar = 10", []));
794+
/// try!(trans.execute("UPDATE foo SET bar = 10", &[]));
800795
/// // ...
801796
///
802797
/// try!(trans.commit());
@@ -1095,13 +1090,13 @@ impl<'conn> Statement<'conn> {
10951090
values.push(try!(param.to_sql(ty)));
10961091
};
10971092

1098-
try!(conn.write_messages([
1093+
try!(conn.write_messages(&[
10991094
Bind {
11001095
portal: portal_name,
11011096
statement: self.name[],
1102-
formats: [1],
1097+
formats: &[1],
11031098
values: values[],
1104-
result_formats: [1]
1099+
result_formats: &[1]
11051100
},
11061101
Execute {
11071102
portal: portal_name,
@@ -1190,7 +1185,7 @@ impl<'conn> Statement<'conn> {
11901185
break;
11911186
}
11921187
CopyInResponse { .. } => {
1193-
try!(conn.write_messages([
1188+
try!(conn.write_messages(&[
11941189
CopyFail {
11951190
message: "COPY queries cannot be directly executed",
11961191
},
@@ -1273,7 +1268,7 @@ impl<'stmt> Rows<'stmt> {
12731268
fn finish_inner(&mut self) -> Result<()> {
12741269
let mut conn = self.stmt.conn.conn.borrow_mut();
12751270
check_desync!(conn);
1276-
try!(conn.write_messages([
1271+
try!(conn.write_messages(&[
12771272
Close {
12781273
variant: b'P',
12791274
name: self.name[]
@@ -1312,7 +1307,7 @@ impl<'stmt> Rows<'stmt> {
13121307
return DbError::new(fields);
13131308
}
13141309
CopyInResponse { .. } => {
1315-
try!(conn.write_messages([
1310+
try!(conn.write_messages(&[
13161311
CopyFail {
13171312
message: "COPY queries cannot be directly executed",
13181313
},
@@ -1328,7 +1323,7 @@ impl<'stmt> Rows<'stmt> {
13281323
}
13291324

13301325
fn execute(&mut self) -> Result<()> {
1331-
try!(self.stmt.conn.write_messages([
1326+
try!(self.stmt.conn.write_messages(&[
13321327
Execute {
13331328
portal: self.name[],
13341329
max_rows: self.row_limit
@@ -1417,7 +1412,7 @@ impl<'stmt> Row<'stmt> {
14171412
/// # use postgres::{Connection, SslMode};
14181413
/// # let conn = Connection::connect("", &SslMode::None).unwrap();
14191414
/// # let stmt = conn.prepare("").unwrap();
1420-
/// # let mut result = stmt.query([]).unwrap();
1415+
/// # let mut result = stmt.query(&[]).unwrap();
14211416
/// # let row = result.next().unwrap();
14221417
/// let foo: i32 = row.get(0u);
14231418
/// let bar: String = row.get("bar");
@@ -1520,13 +1515,13 @@ impl<'a> CopyInStatement<'a> {
15201515
where I: Iterator<J>, J: Iterator<&'b ToSql + 'b> {
15211516
let mut conn = self.conn.conn.borrow_mut();
15221517

1523-
try!(conn.write_messages([
1518+
try!(conn.write_messages(&[
15241519
Bind {
15251520
portal: "",
15261521
statement: self.name[],
1527-
formats: [],
1528-
values: [],
1529-
result_formats: []
1522+
formats: &[],
1523+
values: &[],
1524+
result_formats: &[]
15301525
},
15311526
Execute {
15321527
portal: "",
@@ -1605,7 +1600,7 @@ impl<'a> CopyInStatement<'a> {
16051600
}
16061601

16071602
let _ = buf.write_be_i16(-1);
1608-
try!(conn.write_messages([
1603+
try!(conn.write_messages(&[
16091604
CopyData {
16101605
data: buf.unwrap()[],
16111606
},

src/message.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ fn read_auth_message(buf: &mut MemReader) -> IoResult<BackendMessage> {
373373
3 => AuthenticationCleartextPassword,
374374
5 => {
375375
let mut salt = [0, ..4];
376-
try!(buf.read_at_least(salt.len(), salt));
376+
try!(buf.read_at_least(salt.len(), &mut salt));
377377
AuthenticationMD5Password { salt: salt }
378378
},
379379
6 => AuthenticationSCMCredential,

src/url.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ fn decode_inner<T: BytesContainer>(c: T, full_url: bool) -> DecodeResult<String>
159159
};
160160

161161
// Only decode some characters if full_url:
162-
match num::from_str_radix::<uint>(str::from_utf8(bytes).unwrap(), 16u).unwrap() as u8 as char {
162+
match num::from_str_radix::<uint>(str::from_utf8(&bytes).unwrap(), 16u).unwrap() as u8 as char {
163163
// gen-delims:
164164
':' | '/' | '?' | '#' | '[' | ']' | '@' |
165165

@@ -463,8 +463,8 @@ fn get_query_fragment(rawurl: &str) -> DecodeResult<(Query, Option<String>)> {
463463
};
464464

465465
match before_fragment.slice_shift_char() {
466-
(Some('?'), rest) => Ok((try!(query_from_str(rest)), fragment)),
467-
(None, "") => Ok((vec!(), fragment)),
466+
Some(('?', rest)) => Ok((try!(query_from_str(rest)), fragment)),
467+
None => Ok((vec!(), fragment)),
468468
_ => Err(format!("Query didn't start with '?': '{}..'", before_fragment)),
469469
}
470470
}

0 commit comments

Comments
 (0)