mirror of
https://github.com/isar/rusqlite.git
synced 2025-01-20 07:20:50 +08:00
Merge pull request #3 from marcusklaas/master
fix small error in README; update deprecated method call
This commit is contained in:
commit
a0a488bccb
@ -29,7 +29,7 @@ fn main() {
|
|||||||
name TEXT NOT NULL,
|
name TEXT NOT NULL,
|
||||||
time_created TEXT NOT NULL,
|
time_created TEXT NOT NULL,
|
||||||
data BLOB
|
data BLOB
|
||||||
)", []).unwrap();
|
)", &[]).unwrap();
|
||||||
let me = Person {
|
let me = Person {
|
||||||
id: 0,
|
id: 0,
|
||||||
name: "Steven".to_string(),
|
name: "Steven".to_string(),
|
||||||
@ -41,7 +41,7 @@ fn main() {
|
|||||||
&[&me.name, &me.time_created, &me.data]).unwrap();
|
&[&me.name, &me.time_created, &me.data]).unwrap();
|
||||||
|
|
||||||
let mut stmt = conn.prepare("SELECT id, name, time_created, data FROM person").unwrap();
|
let mut stmt = conn.prepare("SELECT id, name, time_created, data FROM person").unwrap();
|
||||||
for row in stmt.query([]).unwrap().map(|row| row.unwrap()) {
|
for row in stmt.query(&[]).unwrap().map(|row| row.unwrap()) {
|
||||||
let person = Person {
|
let person = Person {
|
||||||
id: row.get(0),
|
id: row.get(0),
|
||||||
name: row.get(1),
|
name: row.get(1),
|
||||||
@ -71,7 +71,7 @@ will panic if you do so. A specific example that will panic:
|
|||||||
```rust
|
```rust
|
||||||
fn bad_function_will_panic(conn: &SqliteConnection) -> SqliteResult<i64> {
|
fn bad_function_will_panic(conn: &SqliteConnection) -> SqliteResult<i64> {
|
||||||
let mut stmt = try!(conn.prepare("SELECT id FROM my_table"));
|
let mut stmt = try!(conn.prepare("SELECT id FROM my_table"));
|
||||||
let mut rows = try!(stmt.query([]));
|
let mut rows = try!(stmt.query(&[]));
|
||||||
|
|
||||||
let row0 = try!(rows.next().unwrap());
|
let row0 = try!(rows.next().unwrap());
|
||||||
// row 0 is valid now...
|
// row 0 is valid now...
|
||||||
|
Loading…
x
Reference in New Issue
Block a user