Remove ouroboros dev dependencies

Keep only self_cell
This commit is contained in:
gwenn 2025-01-25 16:05:36 +01:00
parent 9460849521
commit 508e5058c4
4 changed files with 29 additions and 59 deletions

View File

@ -144,7 +144,6 @@ tempfile = "3.1.0"
regex = "1.5.5"
uuid = { version = "1.0", features = ["v4"] }
unicase = "2.6.0"
ouroboros = "0.18"
self_cell = "1.1.0"
# Use `bencher` over criterion because it builds much faster,
# and we don't have many benchmarks

View File

@ -1,25 +1,23 @@
extern crate rusqlite;
use ouroboros::self_referencing;
use rusqlite::{CachedStatement, Connection, Result, Rows};
use self_cell::{self_cell, MutBorrow};
#[self_referencing]
struct OwningRows<'conn> {
stmt: CachedStatement<'conn>,
#[borrows(mut stmt)]
#[covariant]
rows: Rows<'this>,
}
type RowsRef<'a> = Rows<'a>;
self_cell!(
struct OwningRows<'conn> {
owner: MutBorrow<CachedStatement<'conn>>,
#[covariant]
dependent: RowsRef,
}
);
fn main() -> Result<()> {
let conn = Connection::open_in_memory()?;
let stmt = conn.prepare_cached("SELECT 1")?;
let mut or = OwningRowsTryBuilder {
stmt,
rows_builder: |s| s.query([]),
}
.try_build()?;
or.with_rows_mut(|rows| -> Result<()> {
let mut or = OwningRows::try_new(MutBorrow::new(stmt), |s| s.borrow_mut().query([]))?;
or.with_dependent_mut(|_stmt, rows| -> Result<()> {
while let Some(row) = rows.next()? {
assert_eq!(Ok(1), row.get(0));
}

View File

@ -1,27 +0,0 @@
extern crate rusqlite;
use rusqlite::{CachedStatement, Connection, Result, Rows};
use self_cell::{self_cell, MutBorrow};
type RowsRef<'a> = Rows<'a>;
self_cell!(
struct OwningRows<'conn> {
owner: MutBorrow<CachedStatement<'conn>>,
#[covariant]
dependent: RowsRef,
}
);
fn main() -> Result<()> {
let conn = Connection::open_in_memory()?;
let stmt = conn.prepare_cached("SELECT 1")?;
let mut or = OwningRows::try_new(MutBorrow::new(stmt), |s| s.borrow_mut().query([]))?;
or.with_dependent_mut(|_stmt, rows| -> Result<()> {
while let Some(row) = rows.next()? {
assert_eq!(Ok(1), row.get(0));
}
Ok(())
})?;
Ok(())
}

View File

@ -1,28 +1,28 @@
extern crate rusqlite;
use ouroboros::self_referencing;
use rusqlite::{CachedStatement, Connection, Result, Rows};
use self_cell::{self_cell, MutBorrow};
/// Caveat: single statement at a time for one connection.
/// But if you need multiple statements, you can still create your own struct
/// with multiple fields (one for each statement).
#[self_referencing]
struct OwningStatement {
conn: Connection,
#[borrows(conn)]
#[covariant]
stmt: CachedStatement<'this>,
}
type CachedStatementRef<'a> = CachedStatement<'a>;
// Caveat: single statement at a time for one connection.
// But if you need multiple statements, you can still create your own struct
// with multiple fields (one for each statement).
self_cell!(
struct OwningStatement {
owner: MutBorrow<Connection>,
#[covariant]
dependent: CachedStatementRef,
}
);
fn main() -> Result<()> {
let conn = Connection::open_in_memory()?;
let mut os = OwningStatementTryBuilder {
conn,
stmt_builder: |c| c.prepare_cached("SELECT 1"),
}
.try_build()?;
let mut os = OwningStatement::try_new(MutBorrow::new(conn), |s| {
s.borrow_mut().prepare_cached("SELECT 1")
})?;
let mut rows = os.with_stmt_mut(|stmt| -> Result<Rows<'_>> { stmt.query([]) })?;
let mut rows = os.with_dependent_mut(|_conn, stmt| -> Result<Rows<'_>> { stmt.query([]) })?;
while let Some(row) = rows.next()? {
assert_eq!(Ok(1), row.get(0));
}