Explorar o código

Add Modelable impl for f64.

Kestrel %!s(int64=2) %!d(string=hai) anos
pai
achega
de9317da73
Modificáronse 1 ficheiros con 12 adicións e 0 borrados
  1. 12 0
      microrm/src/model/modelable.rs

+ 12 - 0
microrm/src/model/modelable.rs

@@ -26,6 +26,18 @@ integral!(u32);
 integral!(i64);
 integral!(u64);
 
+impl Modelable for f64 {
+    fn bind_to(&self, stmt: &mut sqlite::Statement, col: usize) -> sqlite::Result<()> {
+        self.bind(stmt, col)
+    }
+    fn build_from(stmt: &sqlite::Statement, col_offset: usize) -> sqlite::Result<(Self, usize)>
+    where
+        Self: Sized,
+    {
+        stmt.read(col_offset).map(|x| (x, 1))
+    }
+}
+
 impl Modelable for bool {
     fn bind_to(&self, stmt: &mut sqlite::Statement, col: usize) -> sqlite::Result<()> {
         let val = if self == &true { 1i64 } else { 0i64 };