Skip to content

Commit aa457cb

Browse files
committed
to_string -> to_str
1 parent f576e87 commit aa457cb

4 files changed

Lines changed: 41 additions & 41 deletions

File tree

src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ macro_rules! make_errors(
2929
pub fn from_code(s: &str) -> PostgresSqlState {
3030
match STATE_MAP.find(&s) {
3131
Some(state) => state.clone(),
32-
None => UnknownSqlState(s.to_string())
32+
None => UnknownSqlState(s.to_str())
3333
}
3434
}
3535
}

src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn main() {
3131
)", []).unwrap();
3232
let me = Person {
3333
id: 0,
34-
name: "Steven".to_string(),
34+
name: "Steven".to_str(),
3535
time_created: time::get_time(),
3636
data: None
3737
};
@@ -284,15 +284,15 @@ impl IntoConnectParams for Url {
284284
let port = match port {
285285
Some(port) => match FromStr::from_str(port.as_slice()) {
286286
Some(port) => Some(port),
287-
None => return Err(InvalidUrl("invalid port".to_string())),
287+
None => return Err(InvalidUrl("invalid port".to_str())),
288288
},
289289
None => None,
290290
};
291291

292292
let database = if !path.is_empty() {
293293
// path contains the leading /
294294
let (_, path) = path.as_slice().slice_shift_char();
295-
Some(path.to_string())
295+
Some(path.to_str())
296296
} else {
297297
None
298298
};
@@ -461,14 +461,14 @@ impl InnerPostgresConnection {
461461
canary: CANARY,
462462
};
463463

464-
options.push(("client_encoding".to_string(), "UTF8".to_string()));
464+
options.push(("client_encoding".to_str(), "UTF8".to_str()));
465465
// Postgres uses the value of TimeZone as the time zone for TIMESTAMP
466466
// WITH TIME ZONE values. Timespec converts to GMT internally.
467-
options.push(("TimeZone".to_string(), "GMT".to_string()));
467+
options.push(("TimeZone".to_str(), "GMT".to_str()));
468468
// We have to clone here since we need the user again for auth
469-
options.push(("user".to_string(), user.clone()));
469+
options.push(("user".to_str(), user.clone()));
470470
match database {
471-
Some(database) => options.push(("database".to_string(), database)),
471+
Some(database) => options.push(("database".to_str(), database)),
472472
None => {}
473473
}
474474

@@ -757,7 +757,7 @@ impl PostgresConnection {
757757
/// let params = PostgresConnectParams {
758758
/// target: TargetUnix(some_crazy_path),
759759
/// port: None,
760-
/// user: Some("postgres".to_string()),
760+
/// user: Some("postgres".to_str()),
761761
/// password: None,
762762
/// database: None,
763763
/// options: vec![],

src/test.rs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,8 @@ fn test_result_descriptions() {
404404
let conn = or_fail!(PostgresConnection::connect("postgres://postgres@localhost", &NoSsl));
405405
let stmt = or_fail!(conn.prepare("SELECT 1::INT as a, 'hi'::VARCHAR as b"));
406406
assert!(stmt.result_descriptions() ==
407-
[ResultDescription { name: "a".to_string(), ty: PgInt4},
408-
ResultDescription { name: "b".to_string(), ty: PgVarchar}]);
407+
[ResultDescription { name: "a".to_str(), ty: PgInt4},
408+
ResultDescription { name: "b".to_str(), ty: PgVarchar}]);
409409
}
410410

411411
#[test]
@@ -447,8 +447,8 @@ fn test_i8_params() {
447447

448448
#[test]
449449
fn test_name_params() {
450-
test_type("NAME", [(Some("hello world".to_string()), "'hello world'"),
451-
(Some("イロハニホヘト チリヌルヲ".to_string()), "'イロハニホヘト チリヌルヲ'"),
450+
test_type("NAME", [(Some("hello world".to_str()), "'hello world'"),
451+
(Some("イロハニホヘト チリヌルヲ".to_str()), "'イロハニホヘト チリヌルヲ'"),
452452
(None, "NULL")]);
453453
}
454454

@@ -488,15 +488,15 @@ fn test_f64_params() {
488488

489489
#[test]
490490
fn test_varchar_params() {
491-
test_type("VARCHAR", [(Some("hello world".to_string()), "'hello world'"),
492-
(Some("イロハニホヘト チリヌルヲ".to_string()), "'イロハニホヘト チリヌルヲ'"),
491+
test_type("VARCHAR", [(Some("hello world".to_str()), "'hello world'"),
492+
(Some("イロハニホヘト チリヌルヲ".to_str()), "'イロハニホヘト チリヌルヲ'"),
493493
(None, "NULL")]);
494494
}
495495

496496
#[test]
497497
fn test_text_params() {
498-
test_type("TEXT", [(Some("hello world".to_string()), "'hello world'"),
499-
(Some("イロハニホヘト チリヌルヲ".to_string()), "'イロハニホヘト チリヌルヲ'"),
498+
test_type("TEXT", [(Some("hello world".to_str()), "'hello world'"),
499+
(Some("イロハニホヘト チリヌルヲ".to_str()), "'イロハニホヘト チリヌルヲ'"),
500500
(None, "NULL")]);
501501
}
502502

@@ -513,7 +513,7 @@ fn test_bpchar_params() {
513513
let stmt = or_fail!(conn.prepare("SELECT b FROM foo ORDER BY id"));
514514
let res = or_fail!(stmt.query([]));
515515

516-
assert_eq!(vec!(Some("12345".to_string()), Some("123 ".to_string()), None),
516+
assert_eq!(vec!(Some("12345".to_str()), Some("123 ".to_str()), None),
517517
res.map(|row| row[1]).collect());
518518
}
519519

@@ -558,7 +558,7 @@ fn test_tm_params() {
558558

559559
macro_rules! test_range(
560560
($name:expr, $t:ty, $low:expr, $low_str:expr, $high:expr, $high_str:expr) => ({
561-
let tests = [(Some(range!('(', ')')), "'(,)'".to_string()),
561+
let tests = [(Some(range!('(', ')')), "'(,)'".to_str()),
562562
(Some(range!('[' $low, ')')), format!("'[{},)'", $low_str)),
563563
(Some(range!('(' $low, ')')), format!("'({},)'", $low_str)),
564564
(Some(range!('(', $high ']')), format!("'(,{}]'", $high_str)),
@@ -571,8 +571,8 @@ macro_rules! test_range(
571571
format!("'({},{}]'", $low_str, $high_str)),
572572
(Some(range!('(' $low, $high ')')),
573573
format!("'({},{})'", $low_str, $high_str)),
574-
(Some(range!(empty)), "'empty'".to_string()),
575-
(None, "NULL".to_string())];
574+
(Some(range!(empty)), "'empty'".to_str()),
575+
(None, "NULL".to_str())];
576576
test_type($name, tests);
577577
})
578578
)
@@ -610,7 +610,7 @@ macro_rules! test_array_params(
610610
($name:expr, $v1:expr, $s1:expr, $v2:expr, $s2:expr, $v3:expr, $s3:expr) => ({
611611
let tests = [(Some(ArrayBase::from_vec(vec!(Some($v1), Some($v2), None), 1)),
612612
format!(r"'\{{},{},NULL\}'", $s1, $s2).into_string()),
613-
(None, "NULL".to_string())];
613+
(None, "NULL".to_str())];
614614
test_type(format!("{}[]", $name).as_slice(), tests);
615615
let mut a = ArrayBase::from_vec(vec!(Some($v1), Some($v2)), 0);
616616
a.wrap(-1);
@@ -640,8 +640,8 @@ fn test_chararray_params() {
640640

641641
#[test]
642642
fn test_namearray_params() {
643-
test_array_params!("NAME", "hello".to_string(), "hello", "world".to_string(),
644-
"world", "!".to_string(), "!");
643+
test_array_params!("NAME", "hello".to_str(), "hello", "world".to_str(),
644+
"world", "!".to_str(), "!");
645645
}
646646

647647
#[test]
@@ -656,20 +656,20 @@ fn test_int4array_params() {
656656

657657
#[test]
658658
fn test_textarray_params() {
659-
test_array_params!("TEXT", "hello".to_string(), "hello", "world".to_string(),
660-
"world", "!".to_string(), "!");
659+
test_array_params!("TEXT", "hello".to_str(), "hello", "world".to_str(),
660+
"world", "!".to_str(), "!");
661661
}
662662

663663
#[test]
664664
fn test_charnarray_params() {
665-
test_array_params!("CHAR(5)", "hello".to_string(), "hello",
666-
"world".to_string(), "world", "! ".to_string(), "!");
665+
test_array_params!("CHAR(5)", "hello".to_str(), "hello",
666+
"world".to_str(), "world", "! ".to_str(), "!");
667667
}
668668

669669
#[test]
670670
fn test_varchararray_params() {
671-
test_array_params!("VARCHAR", "hello".to_string(), "hello",
672-
"world".to_string(), "world", "!".to_string(), "!");
671+
test_array_params!("VARCHAR", "hello".to_str(), "hello",
672+
"world".to_str(), "world", "!".to_str(), "!");
673673
}
674674

675675
#[test]
@@ -753,10 +753,10 @@ fn test_hstore_params() {
753753
})
754754
)
755755
test_type("hstore",
756-
[(Some(make_map!("a".to_string() => Some("1".to_string()))), "'a=>1'"),
757-
(Some(make_map!("hello".to_string() => Some("world!".to_string()),
758-
"hola".to_string() => Some("mundo!".to_string()),
759-
"what".to_string() => None)),
756+
[(Some(make_map!("a".to_str() => Some("1".to_str()))), "'a=>1'"),
757+
(Some(make_map!("hello".to_str() => Some("world!".to_str()),
758+
"hola".to_str() => Some("mundo!".to_str()),
759+
"what".to_str() => None)),
760760
"'hello=>world!,hola=>mundo!,what=>NULL'"),
761761
(None, "NULL")]);
762762
}
@@ -909,21 +909,21 @@ fn test_notification_iterator_some() {
909909

910910
check_notification(PostgresNotification {
911911
pid: 0,
912-
channel: "test_notification_iterator_one_channel".to_string(),
913-
payload: "hello".to_string()
912+
channel: "test_notification_iterator_one_channel".to_str(),
913+
payload: "hello".to_str()
914914
}, it.next());
915915
check_notification(PostgresNotification {
916916
pid: 0,
917-
channel: "test_notification_iterator_one_channel2".to_string(),
918-
payload: "world".to_string()
917+
channel: "test_notification_iterator_one_channel2".to_str(),
918+
payload: "world".to_str()
919919
}, it.next());
920920
assert!(it.next().is_none());
921921

922922
or_fail!(conn.execute("NOTIFY test_notification_iterator_one_channel, '!'", []));
923923
check_notification(PostgresNotification {
924924
pid: 0,
925-
channel: "test_notification_iterator_one_channel".to_string(),
926-
payload: "!".to_string()
925+
channel: "test_notification_iterator_one_channel".to_str(),
926+
payload: "!".to_str()
927927
}, it.next());
928928
assert!(it.next().is_none());
929929
}

src/types/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ macro_rules! make_postgres_type(
9898
match oid {
9999
$($oid => $variant,)+
100100
// We have to load an empty string now, it'll get filled in later
101-
oid => PgUnknownType { name: "".to_string(), oid: oid }
101+
oid => PgUnknownType { name: "".to_str(), oid: oid }
102102
}
103103
}
104104

0 commit comments

Comments
 (0)