mirror of
				https://github.com/isar/rusqlite.git
				synced 2025-10-31 05:48:56 +08:00 
			
		
		
		
	Parse Option<T> into Value/ValueRef where applicable
This commit is contained in:
		| @@ -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> { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user