diff --git a/src/types/mod.rs b/src/types/mod.rs index eeac3287..519bba55 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -253,12 +253,15 @@ macro_rules! make_postgres_type { } /// The kind of this type - pub fn kind(&self) -> Kind { + pub fn kind(&self) -> &Kind { match *self { $( - Type::$variant => $kind, + Type::$variant => { + const V: &'static Kind = &$kind; + V + } )+ - Type::Unknown(ref u) => u.kind().clone(), + Type::Unknown(ref u) => u.kind(), } } } diff --git a/src/types/slice.rs b/src/types/slice.rs index c2957105..87a8a66b 100644 --- a/src/types/slice.rs +++ b/src/types/slice.rs @@ -6,7 +6,7 @@ use {Type, ToSql, Result, Error, Kind}; /// /// `Slice`'s `ToSql` implementation maps the slice to a one-dimensional /// Postgres array of the relevant type. This is particularly useful with the -/// `ANY` operator to match a column against multiple values without having +/// `ANY` function to match a column against multiple values without having /// to dynamically construct the query string. /// /// # Examples @@ -27,7 +27,7 @@ pub struct Slice<'a, T: 'a + ToSql>(pub &'a [T]); impl<'a, T: 'a + ToSql> ToSql for Slice<'a, T> { fn to_sql(&self, ty: &Type) -> Result>> { let member_type = match ty.kind() { - Kind::Array(member) => member, + &Kind::Array(ref member) => member, _ => return Err(Error::WrongType(ty.clone())), };