Fix doc comment example of FromSql implementation.

This commit is contained in:
John Gallagher 2016-05-24 20:12:29 -04:00
parent 0fbfad2452
commit d9df23ca90

View File

@ -15,7 +15,7 @@
//! `"%Y-%m-%d %H:%M:%S"`, as SQLite's builtin //! `"%Y-%m-%d %H:%M:%S"`, as SQLite's builtin
//! [datetime](https://www.sqlite.org/lang_datefunc.html) function. Note that this storage //! [datetime](https://www.sqlite.org/lang_datefunc.html) function. Note that this storage
//! truncates timespecs to the nearest second. If you want different storage for timespecs, you can //! truncates timespecs to the nearest second. If you want different storage for timespecs, you can
//! use a newtype. For example, to store timespecs as doubles: //! use a newtype. For example, to store timespecs as `f64`s:
//! //!
//! ```rust,ignore //! ```rust,ignore
//! extern crate rusqlite; //! extern crate rusqlite;
@ -29,10 +29,8 @@
//! pub struct TimespecSql(pub time::Timespec); //! pub struct TimespecSql(pub time::Timespec);
//! //!
//! impl FromSql for TimespecSql { //! impl FromSql for TimespecSql {
//! unsafe fn column_result(stmt: *mut sqlite3_stmt, col: c_int) //! fn column_result(value: BorrowedValue) -> Result<Self> {
//! -> Result<TimespecSql> { //! f64::column_result(value).map(|as_f64| {
//! let as_f64_result = FromSql::column_result(stmt, col);
//! as_f64_result.map(|as_f64: f64| {
//! TimespecSql(time::Timespec{ sec: as_f64.trunc() as i64, //! TimespecSql(time::Timespec{ sec: as_f64.trunc() as i64,
//! nsec: (as_f64.fract() * 1.0e9) as i32 }) //! nsec: (as_f64.fract() * 1.0e9) as i32 })
//! }) //! })