From 57750fe6a6213f191a9924119413121f10a50357 Mon Sep 17 00:00:00 2001 From: reddraggone9 Date: Tue, 24 Jan 2017 22:57:42 -0600 Subject: [PATCH] Fix doc comment example of FromSql/ToSql Update a doc test so that it compiles on master. Also remove the ignore directive so that it runs with the rest of the test suite. --- src/types/mod.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/types/mod.rs b/src/types/mod.rs index 6e46031..1a49231 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -17,19 +17,17 @@ //! truncates timespecs to the nearest second. If you want different storage for timespecs, you can //! use a newtype. For example, to store timespecs as `f64`s: //! -//! ```rust,ignore +//! ```rust //! extern crate rusqlite; -//! extern crate libc; +//! extern crate time; //! -//! use rusqlite::types::{FromSql, ToSql, sqlite3_stmt}; +//! use rusqlite::types::{FromSql, FromSqlResult, ValueRef, ToSql, ToSqlOutput}; //! use rusqlite::{Result}; -//! use libc::c_int; -//! use time; //! //! pub struct TimespecSql(pub time::Timespec); //! //! impl FromSql for TimespecSql { -//! fn column_result(value: ValueRef) -> Result { +//! fn column_result(value: ValueRef) -> FromSqlResult { //! f64::column_result(value).map(|as_f64| { //! TimespecSql(time::Timespec{ sec: as_f64.trunc() as i64, //! nsec: (as_f64.fract() * 1.0e9) as i32 }) @@ -38,12 +36,15 @@ //! } //! //! impl ToSql for TimespecSql { -//! unsafe fn bind_parameter(&self, stmt: *mut sqlite3_stmt, col: c_int) -> c_int { +//! fn to_sql(&self) -> Result { //! let TimespecSql(ts) = *self; //! let as_f64 = ts.sec as f64 + (ts.nsec as f64) / 1.0e9; -//! as_f64.bind_parameter(stmt, col) +//! Ok(as_f64.into()) //! } //! } +//! +//! # // Prevent this doc test from being wrapped in a `fn main()` so that it will compile. +//! # fn main() {} //! ``` //! //! `ToSql` and `FromSql` are also implemented for `Option` where `T` implements `ToSql` or