Skip to content

Commit c5e7e46

Browse files
committed
Fix deprecation warnings
1 parent 785c674 commit c5e7e46

5 files changed

Lines changed: 20 additions & 20 deletions

File tree

src/error.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,10 +534,10 @@ impl DbError {
534534
detail: map.remove(&b'D'),
535535
hint: map.remove(&b'H'),
536536
position: match map.remove(&b'P') {
537-
Some(pos) => Some(ErrorPosition::Normal(try!(from_str(&*pos).ok_or(())))),
537+
Some(pos) => Some(ErrorPosition::Normal(try!(pos.parse().ok_or(())))),
538538
None => match map.remove(&b'p') {
539539
Some(pos) => Some(ErrorPosition::Internal {
540-
position: try!(from_str(&*pos).ok_or(())),
540+
position: try!(pos.parse().ok_or(())),
541541
query: try!(map.remove(&b'q').ok_or(()))
542542
}),
543543
None => None
@@ -550,7 +550,7 @@ impl DbError {
550550
datatype: map.remove(&b'd'),
551551
constraint: map.remove(&b'n'),
552552
file: try!(map.remove(&b'F').ok_or(())),
553-
line: try!(map.remove(&b'L').and_then(|l| from_str(&*l)).ok_or(())),
553+
line: try!(map.remove(&b'L').and_then(|l| l.parse()).ok_or(())),
554554
routine: try!(map.remove(&b'R').ok_or(())),
555555
})
556556
}

src/lib.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
//! )", &[]).unwrap();
3030
//! let me = Person {
3131
//! id: 0,
32-
//! name: "Steven".into_string(),
32+
//! name: "Steven".to_string(),
3333
//! time_created: time::get_time(),
3434
//! data: None
3535
//! };
@@ -65,6 +65,7 @@ extern crate time;
6565
use openssl::crypto::hash::{HashType, Hasher};
6666
use openssl::ssl::{SslContext, MaybeSslStream};
6767
use serialize::hex::ToHex;
68+
use std::borrow::ToOwned;
6869
use std::cell::{Cell, RefCell};
6970
use std::cmp::max;
7071
use std::collections::{RingBuf, HashMap};
@@ -182,7 +183,7 @@ impl IntoConnectParams for Url {
182183
});
183184

184185
// path contains the leading /
185-
let database = path.slice_shift_char().map(|(_, path)| path.into_string());
186+
let database = path.slice_shift_char().map(|(_, path)| path.to_owned());
186187

187188
Ok(ConnectParams {
188189
target: target,
@@ -414,14 +415,14 @@ impl InnerConnection {
414415
canary: CANARY,
415416
};
416417

417-
options.push(("client_encoding".into_string(), "UTF8".into_string()));
418+
options.push(("client_encoding".to_owned(), "UTF8".to_owned()));
418419
// Postgres uses the value of TimeZone as the time zone for TIMESTAMP
419420
// WITH TIME ZONE values. Timespec converts to GMT internally.
420-
options.push(("TimeZone".into_string(), "GMT".into_string()));
421+
options.push(("TimeZone".to_owned(), "GMT".to_owned()));
421422
// We have to clone here since we need the user again for auth
422-
options.push(("user".into_string(), user.user.clone()));
423+
options.push(("user".to_owned(), user.user.clone()));
423424
if let Some(database) = database {
424-
options.push(("database".into_string(), database));
425+
options.push(("database".to_owned(), database));
425426
}
426427

427428
try!(conn.write_messages(&[StartupMessage {
@@ -743,7 +744,7 @@ impl InnerConnection {
743744
ReadyForQuery { .. } => break,
744745
DataRow { row } => {
745746
result.push(row.into_iter().map(|opt| {
746-
opt.map(|b| String::from_utf8_lossy(&*b).into_string())
747+
opt.map(|b| String::from_utf8_lossy(&*b).into_owned())
747748
}).collect());
748749
}
749750
CopyInResponse { .. } => {
@@ -822,7 +823,7 @@ impl Connection {
822823
/// target: ConnectTarget::Unix(some_crazy_path),
823824
/// port: None,
824825
/// user: Some(UserInfo {
825-
/// user: "postgres".into_string(),
826+
/// user: "postgres".to_string(),
826827
/// password: None
827828
/// }),
828829
/// database: None,
@@ -895,7 +896,7 @@ impl Connection {
895896
/// )", &[]));
896897
///
897898
/// let stmt = try!(conn.prepare_copy_in("foo", &["bar", "baz"]));
898-
/// let data: &[&[&ToSql]] = &[&[&0i32, &"blah".into_string()],
899+
/// let data: &[&[&ToSql]] = &[&[&0i32, &"blah"],
899900
/// &[&1i32, &None::<String>]];
900901
/// try!(stmt.execute(data.iter().map(|r| r.iter().map(|&e| e))));
901902
/// # Ok(()) };
@@ -959,7 +960,7 @@ impl Connection {
959960
let (param_types, result_desc) = try!(self.conn.borrow_mut().raw_prepare("", query));
960961
let stmt = Statement {
961962
conn: self,
962-
name: "".into_string(),
963+
name: "".to_owned(),
963964
param_types: param_types,
964965
result_desc: result_desc,
965966
next_portal_id: Cell::new(0),

src/types/array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ impl<T> ArrayBase<T> {
148148

149149
/// Returns an iterator over the values in this array, in the
150150
/// higher-dimensional equivalent of row-major order.
151-
pub fn values<'a>(&'a self) -> slice::Items<'a, T> {
151+
pub fn values<'a>(&'a self) -> slice::Iter<'a, T> {
152152
self.data.iter()
153153
}
154154
}

src/util.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,5 @@ pub fn comma_join<'a, W, I>(writer: &mut W, mut strs: I) -> IoResult<()>
1414
}
1515

1616
pub fn parse_update_count(tag: String) -> uint {
17-
let s = tag.split(' ').last().unwrap();
18-
from_str(s).unwrap_or(0)
17+
tag.split(' ').last().unwrap().parse().unwrap_or(0)
1918
}

tests/types/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,18 +188,18 @@ fn test_json_params() {
188188

189189
#[test]
190190
fn test_inet_params() {
191-
test_type("INET", &[(Some(from_str::<IpAddr>("127.0.0.1").unwrap()),
191+
test_type("INET", &[(Some("127.0.0.1".parse::<IpAddr>().unwrap()),
192192
"'127.0.0.1'"),
193-
(Some(from_str("2001:0db8:85a3:0000:0000:8a2e:0370:7334").unwrap()),
193+
(Some("2001:0db8:85a3:0000:0000:8a2e:0370:7334".parse::<IpAddr>().unwrap()),
194194
"'2001:0db8:85a3:0000:0000:8a2e:0370:7334'"),
195195
(None, "NULL")])
196196
}
197197

198198
#[test]
199199
fn test_cidr_params() {
200-
test_type("CIDR", &[(Some(from_str::<IpAddr>("127.0.0.1").unwrap()),
200+
test_type("CIDR", &[(Some("127.0.0.1".parse::<IpAddr>().unwrap()),
201201
"'127.0.0.1'"),
202-
(Some(from_str("2001:0db8:85a3:0000:0000:8a2e:0370:7334").unwrap()),
202+
(Some("2001:0db8:85a3:0000:0000:8a2e:0370:7334".parse::<IpAddr>().unwrap()),
203203
"'2001:0db8:85a3:0000:0000:8a2e:0370:7334'"),
204204
(None, "NULL")])
205205
}

0 commit comments

Comments
 (0)