mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-23 00:39:20 +08:00
Merge pull request #352 from jgallagher/fix-coherence-issue
merge coherence issue fix
This commit is contained in:
commit
89f38b4098
@ -15,6 +15,8 @@ pub enum ToSqlOutput<'a> {
|
|||||||
ZeroBlob(i32),
|
ZeroBlob(i32),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Generically allow any type that can be converted into a ValueRef
|
||||||
|
// to be converted into a ToSqlOutput as well.
|
||||||
impl<'a, T: ?Sized> From<&'a T> for ToSqlOutput<'a>
|
impl<'a, T: ?Sized> From<&'a T> for ToSqlOutput<'a>
|
||||||
where &'a T: Into<ValueRef<'a>>
|
where &'a T: Into<ValueRef<'a>>
|
||||||
{
|
{
|
||||||
@ -23,11 +25,31 @@ impl<'a, T: ?Sized> From<&'a T> for ToSqlOutput<'a>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T: Into<Value>> From<T> for ToSqlOutput<'a> {
|
// We cannot also generically allow any type that can be converted
|
||||||
fn from(t: T) -> Self {
|
// into a Value to be converted into a ToSqlOutput because of
|
||||||
ToSqlOutput::Owned(t.into())
|
// coherence rules (https://github.com/rust-lang/rust/pull/46192),
|
||||||
}
|
// so we'll manually implement it for all the types we know can
|
||||||
|
// be converted into Values.
|
||||||
|
macro_rules! from_value(
|
||||||
|
($t:ty) => (
|
||||||
|
impl<'a> From<$t> for ToSqlOutput<'a> {
|
||||||
|
fn from(t: $t) -> Self { ToSqlOutput::Owned(t.into())}
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
from_value!(String);
|
||||||
|
from_value!(Null);
|
||||||
|
from_value!(bool);
|
||||||
|
from_value!(i8);
|
||||||
|
from_value!(i16);
|
||||||
|
from_value!(i32);
|
||||||
|
from_value!(i64);
|
||||||
|
from_value!(isize);
|
||||||
|
from_value!(u8);
|
||||||
|
from_value!(u16);
|
||||||
|
from_value!(u32);
|
||||||
|
from_value!(f64);
|
||||||
|
from_value!(Vec<u8>);
|
||||||
|
|
||||||
impl<'a> ToSql for ToSqlOutput<'a> {
|
impl<'a> ToSql for ToSqlOutput<'a> {
|
||||||
fn to_sql(&self) -> Result<ToSqlOutput> {
|
fn to_sql(&self) -> Result<ToSqlOutput> {
|
||||||
|
Loading…
Reference in New Issue
Block a user