mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-22 16:29:20 +08:00
Parse Option<T> into Value/ValueRef where applicable
This commit is contained in:
parent
104188055e
commit
49f48a5c56
@ -96,6 +96,16 @@ impl From<Vec<u8>> for Value {
|
||||
}
|
||||
}
|
||||
|
||||
impl <T> From<Option<T>> for Value
|
||||
where T: Into<Value> {
|
||||
fn from(v: Option<T>) -> Value {
|
||||
match v {
|
||||
Some(x) => x.into(),
|
||||
None => Value::Null,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Value {
|
||||
pub fn data_type(&self) -> Type {
|
||||
match *self {
|
||||
|
@ -110,6 +110,16 @@ impl<'a> From<&'a Value> for ValueRef<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T> From<Option<T>> for ValueRef<'a>
|
||||
where T: Into<ValueRef<'a>> {
|
||||
fn from(s: Option<T>) -> ValueRef<'a> {
|
||||
match s {
|
||||
Some(x) => x.into(),
|
||||
None => ValueRef::Null,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "functions", feature = "session", feature = "vtab"))]
|
||||
impl<'a> ValueRef<'a> {
|
||||
pub(crate) unsafe fn from_value(value: *mut crate::ffi::sqlite3_value) -> ValueRef<'a> {
|
||||
|
Loading…
Reference in New Issue
Block a user