mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-26 19:41:37 +08:00
Clean examples
Remove `extern crate` usages. Rustfmt.
This commit is contained in:
parent
dbc48fcde9
commit
0a46a34e3d
@ -14,8 +14,6 @@
|
|||||||
//! ## Example
|
//! ## Example
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! extern crate rusqlite;
|
|
||||||
//!
|
|
||||||
//! use rusqlite::blob::ZeroBlob;
|
//! use rusqlite::blob::ZeroBlob;
|
||||||
//! use rusqlite::{Connection, DatabaseName, NO_PARAMS};
|
//! use rusqlite::{Connection, DatabaseName, NO_PARAMS};
|
||||||
//! use std::io::{Read, Seek, SeekFrom, Write};
|
//! use std::io::{Read, Seek, SeekFrom, Write};
|
||||||
|
@ -9,9 +9,6 @@
|
|||||||
//! module.
|
//! module.
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! extern crate rusqlite;
|
|
||||||
//! extern crate regex;
|
|
||||||
//!
|
|
||||||
//! use regex::Regex;
|
//! use regex::Regex;
|
||||||
//! use rusqlite::{Connection, Error, Result, NO_PARAMS};
|
//! use rusqlite::{Connection, Error, Result, NO_PARAMS};
|
||||||
//! use std::collections::HashMap;
|
//! use std::collections::HashMap;
|
||||||
|
13
src/lib.rs
13
src/lib.rs
@ -2,11 +2,8 @@
|
|||||||
//! expose an interface similar to [rust-postgres](https://github.com/sfackler/rust-postgres).
|
//! expose an interface similar to [rust-postgres](https://github.com/sfackler/rust-postgres).
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! extern crate rusqlite;
|
|
||||||
//! extern crate time;
|
|
||||||
//!
|
|
||||||
//! use rusqlite::types::ToSql;
|
//! use rusqlite::types::ToSql;
|
||||||
//! use rusqlite::{Connection, params};
|
//! use rusqlite::{params, Connection};
|
||||||
//! use time::Timespec;
|
//! use time::Timespec;
|
||||||
//!
|
//!
|
||||||
//! #[derive(Debug)]
|
//! #[derive(Debug)]
|
||||||
@ -146,7 +143,6 @@ const STATEMENT_CACHE_DEFAULT_CAPACITY: usize = 16;
|
|||||||
/// To be used when your statement has no [parameter](https://sqlite.org/lang_expr.html#varparam).
|
/// To be used when your statement has no [parameter](https://sqlite.org/lang_expr.html#varparam).
|
||||||
pub const NO_PARAMS: &[&dyn ToSql] = &[];
|
pub const NO_PARAMS: &[&dyn ToSql] = &[];
|
||||||
|
|
||||||
|
|
||||||
/// A macro making it more convenient to pass heterogeneous lists
|
/// A macro making it more convenient to pass heterogeneous lists
|
||||||
/// of parameters as a `&[&dyn ToSql]`.
|
/// of parameters as a `&[&dyn ToSql]`.
|
||||||
///
|
///
|
||||||
@ -1715,12 +1711,7 @@ mod test {
|
|||||||
let mut insert_stmt = db.prepare("INSERT INTO foo(i, x) VALUES(?, ?)").unwrap();
|
let mut insert_stmt = db.prepare("INSERT INTO foo(i, x) VALUES(?, ?)").unwrap();
|
||||||
for (i, v) in vals.iter().enumerate() {
|
for (i, v) in vals.iter().enumerate() {
|
||||||
let i_to_insert = i as i64;
|
let i_to_insert = i as i64;
|
||||||
assert_eq!(
|
assert_eq!(insert_stmt.execute(params![i_to_insert, v]).unwrap(), 1);
|
||||||
insert_stmt
|
|
||||||
.execute(params![i_to_insert, v])
|
|
||||||
.unwrap(),
|
|
||||||
1
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut query = db.prepare("SELECT i, x FROM foo").unwrap();
|
let mut query = db.prepare("SELECT i, x FROM foo").unwrap();
|
||||||
|
@ -112,8 +112,8 @@ impl<'conn> Statement<'conn> {
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// Note, the `named_params` macro is provided for syntactic convenience, and
|
/// Note, the `named_params` macro is provided for syntactic convenience,
|
||||||
/// so the above example could also be written as:
|
/// and so the above example could also be written as:
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # use rusqlite::{Connection, Result, named_params};
|
/// # use rusqlite::{Connection, Result, named_params};
|
||||||
@ -216,8 +216,8 @@ impl<'conn> Statement<'conn> {
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// Note, the `named_params!` macro is provided for syntactic convenience, and
|
/// Note, the `named_params!` macro is provided for syntactic convenience,
|
||||||
/// so the above example could also be written as:
|
/// and so the above example could also be written as:
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # use rusqlite::{Connection, Result, named_params};
|
/// # use rusqlite::{Connection, Result, named_params};
|
||||||
|
@ -19,9 +19,6 @@
|
|||||||
//! store timespecs as `f64`s:
|
//! store timespecs as `f64`s:
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! extern crate rusqlite;
|
|
||||||
//! extern crate time;
|
|
||||||
//!
|
|
||||||
//! use rusqlite::types::{FromSql, FromSqlResult, ToSql, ToSqlOutput, ValueRef};
|
//! use rusqlite::types::{FromSql, FromSqlResult, ToSql, ToSqlOutput, ValueRef};
|
||||||
//! use rusqlite::Result;
|
//! use rusqlite::Result;
|
||||||
//!
|
//!
|
||||||
@ -77,7 +74,6 @@ mod value_ref;
|
|||||||
/// ## Example
|
/// ## Example
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # extern crate rusqlite;
|
|
||||||
/// # use rusqlite::{Connection, Result};
|
/// # use rusqlite::{Connection, Result};
|
||||||
/// # use rusqlite::types::{Null};
|
/// # use rusqlite::types::{Null};
|
||||||
/// fn main() {}
|
/// fn main() {}
|
||||||
|
Loading…
Reference in New Issue
Block a user