Return references from Type::kind
This commit is contained in:
@@ -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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Option<Vec<u8>>> {
|
||||
let member_type = match ty.kind() {
|
||||
Kind::Array(member) => member,
|
||||
&Kind::Array(ref member) => member,
|
||||
_ => return Err(Error::WrongType(ty.clone())),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user