Delegate to inner type for encode_format
In the ToSql impls for &T and Option<T>, override encode_format to delegate to the impl for T. This ensures that if T overrides this method, it also overrides it for &T and Option<T>.
This commit is contained in:
parent
f048f39812
commit
0d11db6940
@ -868,6 +868,10 @@ where
|
|||||||
T::accepts(ty)
|
T::accepts(ty)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn encode_format(&self) -> Format {
|
||||||
|
(*self).encode_format()
|
||||||
|
}
|
||||||
|
|
||||||
to_sql_checked!();
|
to_sql_checked!();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -887,6 +891,13 @@ impl<T: ToSql> ToSql for Option<T> {
|
|||||||
<T as ToSql>::accepts(ty)
|
<T as ToSql>::accepts(ty)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn encode_format(&self) -> Format {
|
||||||
|
match self {
|
||||||
|
Some(ref val) => val.encode_format(),
|
||||||
|
None => Format::Binary,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
to_sql_checked!();
|
to_sql_checked!();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user