2024-04-04 10:21:33 +00:00
|
|
|
#[salsa::jar(db = Db)]
|
2024-05-24 01:16:30 +00:00
|
|
|
pub struct Jar(MyTracked<'_>, my_fn);
|
2024-04-04 10:21:33 +00:00
|
|
|
|
|
|
|
pub trait Db: salsa::DbWithJar<Jar> {}
|
|
|
|
|
|
|
|
#[salsa::db(Jar)]
|
|
|
|
#[derive(Default)]
|
|
|
|
struct Database {
|
|
|
|
storage: salsa::Storage<Self>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl salsa::Database for Database {}
|
|
|
|
|
|
|
|
impl Db for Database {}
|
|
|
|
|
|
|
|
#[salsa::tracked]
|
2024-05-24 01:16:30 +00:00
|
|
|
pub struct MyTracked<'db> {
|
2024-04-04 10:21:33 +00:00
|
|
|
field: u32,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[salsa::tracked]
|
|
|
|
fn my_fn(db: &dyn crate::Db) {
|
|
|
|
let x = MyTracked::new(db, 22);
|
|
|
|
x.field(22);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2024-05-13 09:13:34 +00:00
|
|
|
let db = Database::default();
|
2024-04-04 10:21:33 +00:00
|
|
|
my_fn(&db);
|
|
|
|
}
|