mirror of
https://github.com/isar/rusqlite.git
synced 2025-09-16 20:52:19 +08:00
Do not panic by default
Replace `Row::get` by `Row::get_checked`, And rename original `Row::get` to `Row::get_unwrap`. `Stmt::query_map`, `Stmt::query_map_named`, `Stmt::query_row`, `Conn::query_row` and `Conn::query_row_named` callback parameter must return a `Result`.
This commit is contained in:
12
README.md
12
README.md
@@ -49,12 +49,12 @@ fn main() -> Result<()> {
|
||||
let mut stmt = conn
|
||||
.prepare("SELECT id, name, time_created, data FROM person")?;
|
||||
let person_iter = stmt
|
||||
.query_map(NO_PARAMS, |row| Person {
|
||||
id: row.get(0),
|
||||
name: row.get(1),
|
||||
time_created: row.get(2),
|
||||
data: row.get(3),
|
||||
})?;
|
||||
.query_map(NO_PARAMS, |row| Ok(Person {
|
||||
id: row.get(0)?,
|
||||
name: row.get(1)?,
|
||||
time_created: row.get(2)?,
|
||||
data: row.get(3)?,
|
||||
}))?;
|
||||
|
||||
for person in person_iter {
|
||||
println!("Found person {:?}", person.unwrap());
|
||||
|
Reference in New Issue
Block a user