Description
How I faced it:
$ rustup update
$ cargo new sqlite_demo --bin
Created binary (application) sqlite_demo
project
rust$ rustc --version
rustc 1.16.0 (30cf806 2017-03-10)
$ cd sqlite_demo/
Add rusqlite dependency into Cargo.toml:
[package]
name = "sqlite_demo"
version = "0.1.0"
authors = ["..."]
[dependencies]
rusqlite = "*" <-- this one was added
$ cargo build
Blocking waiting for file lock on the registry index
Updating registry `https://github.com/rust-lang/crates.io-index`
Blocking waiting for file lock on rusqlite-0.10.1.crate
Downloading libsqlite3-sys v0.7.1
Downloading lru-cache v0.1.0
Downloading time v0.1.36
Downloading pkg-config v0.3.9
Downloading linked-hash-map v0.2.1
Blocking waiting for file lock on libc-0.2.21.crate
Compiling libc v0.2.21
Compiling time v0.1.36
Compiling bitflags v0.7.0
Compiling linked-hash-map v0.2.1
Compiling lru-cache v0.1.0
Compiling pkg-config v0.3.9
Compiling libsqlite3-sys v0.7.1
Compiling rusqlite v0.10.1
Compiling sqlite_demo v0.1.0 (file:///home/seb/workspace/rust/sqlite_demo)
Finished dev [unoptimized + debuginfo] target(s) in 47.84 secs
copy/paste content of main.rs from the demo (http://jgallagher.github.io/rusqlite/rusqlite/index.html):
extern crate rusqlite;
extern crate time;
use time::Timespec;
use rusqlite::Connection;
#[derive(Debug)]
struct Person {
id: i32,
name: String,
time_created: Timespec,
data: Option<Vec<u8>>
}
fn main() {
let conn = Connection::open_in_memory().unwrap();
conn.execute("CREATE TABLE person (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
time_created TEXT NOT NULL,
data BLOB
)", &[]).unwrap();
let me = Person {
id: 0,
name: "Steven".to_string(),
time_created: time::get_time(),
data: None
};
conn.execute("INSERT INTO person (name, time_created, data)
VALUES (?1, ?2, ?3)",
&[&me.name, &me.time_created, &me.data]).unwrap();
let mut stmt = conn.prepare("SELECT id, name, time_created, data FROM person").unwrap();
let person_iter = stmt.query_map(&[], |row| {
Person {
id: row.get(0),
name: row.get(1),
time_created: row.get(2),
data: row.get(3)
}
}).unwrap();
for person in person_iter {
println!("Found person {:?}", person.unwrap());
}
}
$ cargo check
Compiling bitflags v0.7.0
Compiling linked-hash-map v0.2.1
Compiling lru-cache v0.1.0
Compiling libc v0.2.21
Compiling time v0.1.36
Compiling libsqlite3-sys v0.7.1
Compiling rusqlite v0.10.1
Compiling sqlite_demo v0.1.0 (file:///home/seb/workspace/rust/sqlite_demo)
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
thread 'rustc' panicked at 'called Option::unwrap()
on a None
value', /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libcore/option.rs:323
note: Run with RUST_BACKTRACE=1
for a backtrace.
error: Could not compile sqlite_demo
.
To learn more, run the command again with --verbose.
$ rustc --version --verbose
rustc 1.16.0 (30cf806 2017-03-10)
binary: rustc
commit-hash: 30cf806
commit-date: 2017-03-10
host: x86_64-unknown-linux-gnu
release: 1.16.0
LLVM version: 3.9