Parcourir la source

Add Modelable impl for f64.

Kestrel il y a 2 ans
Parent
commit
de9317da73
1 fichiers modifiés avec 12 ajouts et 0 suppressions
  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 };