to_string -> to_str

This commit is contained in:
Steven Fackler 2014-06-05 23:32:49 -07:00
parent f576e874b5
commit aa457cb5be
4 changed files with 41 additions and 41 deletions

View File

@ -29,7 +29,7 @@ macro_rules! make_errors(
pub fn from_code(s: &str) -> PostgresSqlState {
match STATE_MAP.find(&s) {
Some(state) => state.clone(),
None => UnknownSqlState(s.to_string())
None => UnknownSqlState(s.to_str())
}
}
}

View File

@ -31,7 +31,7 @@ fn main() {
)", []).unwrap();
let me = Person {
id: 0,
name: "Steven".to_string(),
name: "Steven".to_str(),
time_created: time::get_time(),
data: None
};
@ -284,7 +284,7 @@ impl IntoConnectParams for Url {
let port = match port {
Some(port) => match FromStr::from_str(port.as_slice()) {
Some(port) => Some(port),
None => return Err(InvalidUrl("invalid port".to_string())),
None => return Err(InvalidUrl("invalid port".to_str())),
},
None => None,
};
@ -292,7 +292,7 @@ impl IntoConnectParams for Url {
let database = if !path.is_empty() {
// path contains the leading /
let (_, path) = path.as_slice().slice_shift_char();
Some(path.to_string())
Some(path.to_str())
} else {
None
};
@ -461,14 +461,14 @@ impl InnerPostgresConnection {
canary: CANARY,
};
options.push(("client_encoding".to_string(), "UTF8".to_string()));
options.push(("client_encoding".to_str(), "UTF8".to_str()));
// Postgres uses the value of TimeZone as the time zone for TIMESTAMP
// WITH TIME ZONE values. Timespec converts to GMT internally.
options.push(("TimeZone".to_string(), "GMT".to_string()));
options.push(("TimeZone".to_str(), "GMT".to_str()));
// We have to clone here since we need the user again for auth
options.push(("user".to_string(), user.clone()));
options.push(("user".to_str(), user.clone()));
match database {
Some(database) => options.push(("database".to_string(), database)),
Some(database) => options.push(("database".to_str(), database)),
None => {}
}
@ -757,7 +757,7 @@ impl PostgresConnection {
/// let params = PostgresConnectParams {
/// target: TargetUnix(some_crazy_path),
/// port: None,
/// user: Some("postgres".to_string()),
/// user: Some("postgres".to_str()),
/// password: None,
/// database: None,
/// options: vec![],

View File

@ -404,8 +404,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".to_string(), ty: PgInt4},
ResultDescription { name: "b".to_string(), ty: PgVarchar}]);
[ResultDescription { name: "a".to_str(), ty: PgInt4},
ResultDescription { name: "b".to_str(), ty: PgVarchar}]);
}
#[test]
@ -447,8 +447,8 @@ fn test_i8_params() {
#[test]
fn test_name_params() {
test_type("NAME", [(Some("hello world".to_string()), "'hello world'"),
(Some("イロハニホヘト チリヌルヲ".to_string()), "'イロハニホヘト チリヌルヲ'"),
test_type("NAME", [(Some("hello world".to_str()), "'hello world'"),
(Some("イロハニホヘト チリヌルヲ".to_str()), "'イロハニホヘト チリヌルヲ'"),
(None, "NULL")]);
}
@ -488,15 +488,15 @@ fn test_f64_params() {
#[test]
fn test_varchar_params() {
test_type("VARCHAR", [(Some("hello world".to_string()), "'hello world'"),
(Some("イロハニホヘト チリヌルヲ".to_string()), "'イロハニホヘト チリヌルヲ'"),
test_type("VARCHAR", [(Some("hello world".to_str()), "'hello world'"),
(Some("イロハニホヘト チリヌルヲ".to_str()), "'イロハニホヘト チリヌルヲ'"),
(None, "NULL")]);
}
#[test]
fn test_text_params() {
test_type("TEXT", [(Some("hello world".to_string()), "'hello world'"),
(Some("イロハニホヘト チリヌルヲ".to_string()), "'イロハニホヘト チリヌルヲ'"),
test_type("TEXT", [(Some("hello world".to_str()), "'hello world'"),
(Some("イロハニホヘト チリヌルヲ".to_str()), "'イロハニホヘト チリヌルヲ'"),
(None, "NULL")]);
}
@ -513,7 +513,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!(vec!(Some("12345".to_string()), Some("123 ".to_string()), None),
assert_eq!(vec!(Some("12345".to_str()), Some("123 ".to_str()), None),
res.map(|row| row[1]).collect());
}
@ -558,7 +558,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!('(', ')')), "'(,)'".to_string()),
let tests = [(Some(range!('(', ')')), "'(,)'".to_str()),
(Some(range!('[' $low, ')')), format!("'[{},)'", $low_str)),
(Some(range!('(' $low, ')')), format!("'({},)'", $low_str)),
(Some(range!('(', $high ']')), format!("'(,{}]'", $high_str)),
@ -571,8 +571,8 @@ macro_rules! test_range(
format!("'({},{}]'", $low_str, $high_str)),
(Some(range!('(' $low, $high ')')),
format!("'({},{})'", $low_str, $high_str)),
(Some(range!(empty)), "'empty'".to_string()),
(None, "NULL".to_string())];
(Some(range!(empty)), "'empty'".to_str()),
(None, "NULL".to_str())];
test_type($name, tests);
})
)
@ -610,7 +610,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)),
format!(r"'\{{},{},NULL\}'", $s1, $s2).into_string()),
(None, "NULL".to_string())];
(None, "NULL".to_str())];
test_type(format!("{}[]", $name).as_slice(), tests);
let mut a = ArrayBase::from_vec(vec!(Some($v1), Some($v2)), 0);
a.wrap(-1);
@ -640,8 +640,8 @@ fn test_chararray_params() {
#[test]
fn test_namearray_params() {
test_array_params!("NAME", "hello".to_string(), "hello", "world".to_string(),
"world", "!".to_string(), "!");
test_array_params!("NAME", "hello".to_str(), "hello", "world".to_str(),
"world", "!".to_str(), "!");
}
#[test]
@ -656,20 +656,20 @@ fn test_int4array_params() {
#[test]
fn test_textarray_params() {
test_array_params!("TEXT", "hello".to_string(), "hello", "world".to_string(),
"world", "!".to_string(), "!");
test_array_params!("TEXT", "hello".to_str(), "hello", "world".to_str(),
"world", "!".to_str(), "!");
}
#[test]
fn test_charnarray_params() {
test_array_params!("CHAR(5)", "hello".to_string(), "hello",
"world".to_string(), "world", "! ".to_string(), "!");
test_array_params!("CHAR(5)", "hello".to_str(), "hello",
"world".to_str(), "world", "! ".to_str(), "!");
}
#[test]
fn test_varchararray_params() {
test_array_params!("VARCHAR", "hello".to_string(), "hello",
"world".to_string(), "world", "!".to_string(), "!");
test_array_params!("VARCHAR", "hello".to_str(), "hello",
"world".to_str(), "world", "!".to_str(), "!");
}
#[test]
@ -753,10 +753,10 @@ fn test_hstore_params() {
})
)
test_type("hstore",
[(Some(make_map!("a".to_string() => Some("1".to_string()))), "'a=>1'"),
(Some(make_map!("hello".to_string() => Some("world!".to_string()),
"hola".to_string() => Some("mundo!".to_string()),
"what".to_string() => None)),
[(Some(make_map!("a".to_str() => Some("1".to_str()))), "'a=>1'"),
(Some(make_map!("hello".to_str() => Some("world!".to_str()),
"hola".to_str() => Some("mundo!".to_str()),
"what".to_str() => None)),
"'hello=>world!,hola=>mundo!,what=>NULL'"),
(None, "NULL")]);
}
@ -909,21 +909,21 @@ fn test_notification_iterator_some() {
check_notification(PostgresNotification {
pid: 0,
channel: "test_notification_iterator_one_channel".to_string(),
payload: "hello".to_string()
channel: "test_notification_iterator_one_channel".to_str(),
payload: "hello".to_str()
}, it.next());
check_notification(PostgresNotification {
pid: 0,
channel: "test_notification_iterator_one_channel2".to_string(),
payload: "world".to_string()
channel: "test_notification_iterator_one_channel2".to_str(),
payload: "world".to_str()
}, 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".to_string(),
payload: "!".to_string()
channel: "test_notification_iterator_one_channel".to_str(),
payload: "!".to_str()
}, it.next());
assert!(it.next().is_none());
}

View File

@ -98,7 +98,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: "".to_string(), oid: oid }
oid => PgUnknownType { name: "".to_str(), oid: oid }
}
}