From d9a8e261f7bf51cecb20c4665e4e160b630c83d4 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Thu, 7 Nov 2013 22:13:11 -0800 Subject: [PATCH] Revert "Remove superfluous impls" Turns out ~T won't actually autoborrow to &T when casting to a trait object. See mozilla/rust#10347 This reverts commit c2a755dd95315563605ce4e45fecaf6064a59dc0. --- types/mod.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/types/mod.rs b/types/mod.rs index 5d10865a..e9ace91d 100644 --- a/types/mod.rs +++ b/types/mod.rs @@ -436,6 +436,13 @@ to_option_impl!(PgFloat4, f32) to_conversions_impl!(PgFloat8, f64, write_be_f64) to_option_impl!(PgFloat8, f64) +impl ToSql for ~str { + fn to_sql(&self, ty: PostgresType) -> (Format, Option<~[u8]>) { + check_types!(PgVarchar | PgText | PgCharN, ty) + (Text, Some(self.as_bytes().to_owned())) + } +} + impl<'self> ToSql for &'self str { fn to_sql(&self, ty: PostgresType) -> (Format, Option<~[u8]>) { check_types!(PgVarchar | PgText | PgCharN, ty) @@ -446,6 +453,13 @@ impl<'self> ToSql for &'self str { to_option_impl!(PgVarchar | PgText | PgCharN, ~str) to_option_impl!(self, PgVarchar | PgText | PgCharN, &'self str) +impl ToSql for ~[u8] { + fn to_sql(&self, ty: PostgresType) -> (Format, Option<~[u8]>) { + check_types!(PgByteA, ty) + (Binary, Some(self.to_owned())) + } +} + impl<'self> ToSql for &'self [u8] { fn to_sql(&self, ty: PostgresType) -> (Format, Option<~[u8]>) { check_types!(PgByteA, ty)