From 59e548623cdc7df2bf7fcb034d0ddeb1cc08e3c8 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Mon, 21 Apr 2014 21:01:44 -0700 Subject: [PATCH] De ~"" --- src/lib.rs | 10 ++++----- src/test.rs | 54 +++++++++++++++++++++++++----------------------- src/types/mod.rs | 2 +- 3 files changed, 34 insertions(+), 32 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 5602c788..a5cec408 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -31,7 +31,7 @@ fn main() { )", []).unwrap(); let me = Person { id: 0, - name: ~"Steven", + name: "Steven".to_owned(), time_created: time::get_time(), data: None }; @@ -579,14 +579,14 @@ impl InnerPostgresConnection { None => return Err(MissingUser), }; - options.push((~"client_encoding", ~"UTF8")); + options.push(("client_encoding".to_owned(), "UTF8".to_owned())); // Postgres uses the value of TimeZone as the time zone for TIMESTAMP // WITH TIME ZONE values. Timespec converts to GMT internally. - options.push((~"TimeZone", ~"GMT")); + options.push(("TimeZone".to_owned(), "GMT".to_owned())); // We have to clone here since we need the user again for auth - options.push((~"user", user.clone())); + options.push(("user".to_owned(), user.clone())); match database { - Some(database) => options.push((~"database", database)), + Some(database) => options.push(("database".to_owned(), database)), None => {} } diff --git a/src/test.rs b/src/test.rs index 28a4e6d1..3a4181bf 100644 --- a/src/test.rs +++ b/src/test.rs @@ -115,7 +115,7 @@ fn test_unix_connection() { let result = or_fail!(stmt.query([])); let unix_socket_directories: ~str = result.map(|row| row[1]).next().unwrap(); - if unix_socket_directories == ~"" { + if unix_socket_directories.is_empty() { fail!("can't test connect_unix; unix_socket_directories is empty"); } @@ -365,8 +365,8 @@ fn test_result_descriptions() { let conn = or_fail!(PostgresConnection::connect("postgres://postgres@localhost", &NoSsl)); let stmt = or_fail!(conn.prepare("SELECT 1::INT as a, 'hi'::VARCHAR as b")); assert!(stmt.result_descriptions() == - [ResultDescription { name: ~"a", ty: PgInt4}, - ResultDescription { name: ~"b", ty: PgVarchar}]); + [ResultDescription { name: "a".to_owned(), ty: PgInt4}, + ResultDescription { name: "b".to_owned(), ty: PgVarchar}]); } #[test] @@ -442,15 +442,15 @@ fn test_f64_params() { #[test] fn test_varchar_params() { - test_type("VARCHAR", [(Some(~"hello world"), "'hello world'"), - (Some(~"イロハニホヘト チリヌルヲ"), "'イロハニホヘト チリヌルヲ'"), + test_type("VARCHAR", [(Some("hello world".to_owned()), "'hello world'"), + (Some("イロハニホヘト チリヌルヲ".to_owned()), "'イロハニホヘト チリヌルヲ'"), (None, "NULL")]); } #[test] fn test_text_params() { - test_type("TEXT", [(Some(~"hello world"), "'hello world'"), - (Some(~"イロハニホヘト チリヌルヲ"), "'イロハニホヘト チリヌルヲ'"), + test_type("TEXT", [(Some("hello world".to_owned()), "'hello world'"), + (Some("イロハニホヘト チリヌルヲ".to_owned()), "'イロハニホヘト チリヌルヲ'"), (None, "NULL")]); } @@ -467,7 +467,7 @@ fn test_bpchar_params() { let stmt = or_fail!(conn.prepare("SELECT b FROM foo ORDER BY id")); let res = or_fail!(stmt.query([])); - assert_eq!(~[Some(~"12345"), Some(~"123 "), None], + assert_eq!(vec!(Some("12345".to_owned()), Some("123 ".to_owned()), None), res.map(|row| row[1]).collect()); } @@ -512,7 +512,7 @@ fn test_tm_params() { macro_rules! test_range( ($name:expr, $t:ty, $low:expr, $low_str:expr, $high:expr, $high_str:expr) => ({ - let tests = [(Some(range!('(', ')')), ~"'(,)'"), + let tests = [(Some(range!('(', ')')), "'(,)'".to_owned()), (Some(range!('[' $low, ')')), "'[" + $low_str + ",)'"), (Some(range!('(' $low, ')')), "'(" + $low_str + ",)'"), (Some(range!('(', $high ']')), "'(," + $high_str + "]'"), @@ -525,8 +525,8 @@ macro_rules! test_range( "'(" + $low_str + "," + $high_str + "]'"), (Some(range!('(' $low, $high ')')), "'(" + $low_str + "," + $high_str + ")'"), - (Some(range!(empty)), ~"'empty'"), - (None, ~"NULL")]; + (Some(range!(empty)), "'empty'".to_owned()), + (None, "NULL".to_owned())]; test_type($name, tests); }) ) @@ -564,7 +564,7 @@ macro_rules! test_array_params( ($name:expr, $v1:expr, $s1:expr, $v2:expr, $s2:expr, $v3:expr, $s3:expr) => ({ let tests = [(Some(ArrayBase::from_vec(vec!(Some($v1), Some($v2), None), 1)), "'{" + $s1 + "," + $s2 + ",NULL}'"), - (None, ~"NULL")]; + (None, "NULL".to_owned())]; test_type($name + "[]", tests); let mut a = ArrayBase::from_vec(vec!(Some($v1), Some($v2)), 0); a.wrap(-1); @@ -603,18 +603,20 @@ fn test_int4array_params() { #[test] fn test_textarray_params() { - test_array_params!("TEXT", ~"hello", "hello", ~"world", "world", ~"!", "!"); + test_array_params!("TEXT", "hello".to_owned(), "hello", "world".to_owned(), + "world", "!".to_owned(), "!"); } #[test] fn test_charnarray_params() { - test_array_params!("CHAR(5)", ~"hello", "hello", ~"world", "world", - ~"! ", "!"); + test_array_params!("CHAR(5)", "hello".to_owned(), "hello", + "world".to_owned(), "world", "! ".to_owned(), "!"); } #[test] fn test_varchararray_params() { - test_array_params!("VARCHAR", ~"hello", "hello", ~"world", "world", ~"!", "!"); + test_array_params!("VARCHAR", "hello".to_owned(), "hello", + "world".to_owned(), "world", "!".to_owned(), "!"); } #[test] @@ -698,10 +700,10 @@ fn test_hstore_params() { }) ) test_type("hstore", - [(Some(make_map!(~"a" => Some(~"1"))), "'a=>1'"), - (Some(make_map!(~"hello" => Some(~"world!"), - ~"hola" => Some(~"mundo!"), - ~"what" => None)), + [(Some(make_map!("a".to_owned() => Some("1".to_owned()))), "'a=>1'"), + (Some(make_map!("hello".to_owned() => Some("world!".to_owned()), + "hola".to_owned() => Some("mundo!".to_owned()), + "what".to_owned() => None)), "'hello=>world!,hola=>mundo!,what=>NULL'"), (None, "NULL")]); } @@ -853,21 +855,21 @@ fn test_notification_iterator_some() { check_notification(PostgresNotification { pid: 0, - channel: ~"test_notification_iterator_one_channel", - payload: ~"hello" + channel: "test_notification_iterator_one_channel".to_owned(), + payload: "hello".to_owned() }, it.next()); check_notification(PostgresNotification { pid: 0, - channel: ~"test_notification_iterator_one_channel2", - payload: ~"world" + channel: "test_notification_iterator_one_channel2".to_owned(), + payload: "world".to_owned() }, it.next()); assert!(it.next().is_none()); or_fail!(conn.execute("NOTIFY test_notification_iterator_one_channel, '!'", [])); check_notification(PostgresNotification { pid: 0, - channel: ~"test_notification_iterator_one_channel", - payload: ~"!" + channel: "test_notification_iterator_one_channel".to_owned(), + payload: "!".to_owned() }, it.next()); assert!(it.next().is_none()); } diff --git a/src/types/mod.rs b/src/types/mod.rs index 1dfeb590..dad157bf 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -96,7 +96,7 @@ macro_rules! make_postgres_type( match oid { $($oid => $variant,)+ // We have to load an empty string now, it'll get filled in later - oid => PgUnknownType { name: ~"", oid: oid } + oid => PgUnknownType { name: "".to_owned(), oid: oid } } }