Revert "Remove usage of unstable library feature 'duration'"

This reverts commit 9c415f9c9e.
This commit is contained in:
Gwenael Treguier 2015-11-11 15:00:39 +01:00
parent 50bfba1e1d
commit a2327fb048
2 changed files with 7 additions and 4 deletions

View File

@ -50,6 +50,7 @@
//! }
//! }
//! ```
#![cfg_attr(test, feature(duration))]
extern crate libc;
extern crate libsqlite3_sys as ffi;
#[macro_use] extern crate bitflags;

View File

@ -83,17 +83,19 @@ mod test {
super::config_log(None).unwrap();
}
extern "C" fn trace_callback(_: *mut ::libc::c_void, sql: *const ::libc::c_char) {
extern "C" fn profile_callback(_: *mut ::libc::c_void, sql: *const ::libc::c_char, nanoseconds: u64) {
use std::time::Duration;
unsafe {
let c_slice = ::std::ffi::CStr::from_ptr(sql).to_bytes();
let _ = writeln!(::std::io::stderr(), "TRACE: {:?}", ::std::str::from_utf8(c_slice));
let d = Duration::from_millis(nanoseconds / 1_000_000);
let _ = writeln!(::std::io::stderr(), "PROFILE: {:?} ({})", ::std::str::from_utf8(c_slice), d);
}
}
#[test]
fn test_trace() {
fn test_profile() {
let mut db = SqliteConnection::open_in_memory().unwrap();
db.trace(Some(trace_callback));
db.profile(Some(profile_callback));
db.execute_batch("PRAGMA application_id = 1").unwrap();
}
}