Преглед на файлове

Add Modelable impl for f64.

Kestrel преди 2 години
родител
ревизия
de9317da73
променени са 1 файла, в които са добавени 12 реда и са изтрити 0 реда
  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 };