Skip to content

Commit

Permalink
CHECKPOINT to report rust ICE bug. NOT TESTED
Browse files Browse the repository at this point in the history
error: internal compiler error: get_unique_type_id_of_type() - unexpected type: closure, ty_unboxed_closure(syntax::ast::DefId{krate: 0u32, node: 837u32}, ReScope(836u32))

--HG--
branch : rust-closure-issue
  • Loading branch information
dckc committed Sep 17, 2014
1 parent 7519665 commit 882347d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ mod test_opening {
#[cfg(test)]
mod tests {
use super::{DatabaseConnection, SqliteResult, ResultSet};
use super::super::{ResultRowAccess};

#[test]
fn stmt_new_types() {
Expand Down
44 changes: 32 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,23 @@ pub mod ffi;

pub mod access;

pub trait DatabaseUpdate {
fn update<'db, 's>(&'db mut self,
stmt: &'s mut PreparedStatement<'s>,
values: &[&ToSql]) -> SqliteResult<uint>;
}


impl core::DatabaseConnection {
impl DatabaseUpdate for core::DatabaseConnection {
/// Execute a statement after binding any parameters.
///
/// When the statement is done, The [number of rows
/// modified][changes] is reported.
///
/// [changes]: http://www.sqlite.org/c3ref/changes.html
pub fn update<'db, 's>(&'db mut self,
stmt: &'s mut PreparedStatement<'s>,
values: &[&ToSql]) -> SqliteResult<uint> {
fn update<'db, 's>(&'db mut self,
stmt: &'s mut PreparedStatement<'s>,
values: &[&ToSql]) -> SqliteResult<uint> {
let check = {
try!(bind_values(stmt, values));
let mut results = stmt.execute();
Expand All @@ -113,12 +119,20 @@ impl core::DatabaseConnection {
}
}

impl<'s> core::PreparedStatement<'s> {

pub trait Query<'s> {
fn query(&'s mut self,
values: &[&ToSql],
each_row: |&mut ResultRow|: 's -> SqliteResult<()>
) -> SqliteResult<()>;
}

impl<'s> Query<'s> for core::PreparedStatement<'s> {
/// Process rows from a query after binding parameters.
pub fn query(&'s mut self,
values: &[&ToSql],
each_row: |&mut ResultRow|: 's -> SqliteResult<()>
) -> SqliteResult<()> {
fn query(&'s mut self,
values: &[&ToSql],
each_row: |&mut ResultRow|: 's -> SqliteResult<()>
) -> SqliteResult<()> {
try!(bind_values(self, values));
let mut results = self.execute();
loop {
Expand All @@ -140,15 +154,20 @@ fn bind_values<'db>(s: &'db mut PreparedStatement, values: &[&ToSql]) -> SqliteR
}


impl<'s, 'r> core::ResultRow<'s, 'r> {
pub fn get<I: RowIndex + Show + Clone, T: FromSql>(&mut self, idx: I) -> T {
trait ResultRowAccess {
fn get<I: RowIndex + Show + Clone, T: FromSql>(&mut self, idx: I) -> T;
fn get_opt<I: RowIndex, T: FromSql>(&mut self, idx: I) -> SqliteResult<T>;
}

impl<'s, 'r> ResultRowAccess for core::ResultRow<'s, 'r> {
fn get<I: RowIndex + Show + Clone, T: FromSql>(&mut self, idx: I) -> T {
match self.get_opt(idx.clone()) {
Ok(ok) => ok,
Err(err) => fail!("retrieving column {}: {}", idx, err)
}
}
pub fn get_opt<I: RowIndex, T: FromSql>(&mut self, idx: I) -> SqliteResult<T> {
fn get_opt<I: RowIndex, T: FromSql>(&mut self, idx: I) -> SqliteResult<T> {
match idx.idx(self) {
Some(idx) => FromSql::from_sql(self, idx),
None => Err(SQLITE_MISUSE)
Expand Down Expand Up @@ -237,6 +256,7 @@ pub enum ColumnType {
#[cfg(test)]
mod bind_tests {
use super::{DatabaseConnection, ResultSet};
use super::{ResultRowAccess};
use super::{SqliteResult};
#[test]
Expand Down
1 change: 1 addition & 0 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ impl FromSql for time::Timespec {
mod tests {
use time::Tm;
use super::super::{DatabaseConnection, SqliteResult};
use super::super::{ResultRowAccess};

#[test]
fn get_tm() {
Expand Down

0 comments on commit 882347d

Please sign in to comment.