2024-07-19 12:05:39 +00:00
|
|
|
use salsa::prelude::*;
|
2022-09-13 00:18:19 +00:00
|
|
|
|
2024-07-16 10:04:01 +00:00
|
|
|
#[salsa::input]
|
2022-09-13 00:18:19 +00:00
|
|
|
struct MyInput {
|
|
|
|
field: u32,
|
|
|
|
}
|
|
|
|
|
2024-07-16 10:04:01 +00:00
|
|
|
#[salsa::tracked]
|
2024-05-24 01:16:30 +00:00
|
|
|
struct MyTracked<'db> {
|
2022-09-13 00:18:19 +00:00
|
|
|
field: u32,
|
|
|
|
}
|
|
|
|
|
2024-07-16 10:04:01 +00:00
|
|
|
#[salsa::tracked]
|
2024-07-19 12:05:39 +00:00
|
|
|
fn tracked_fn<'db>(db: &'db dyn salsa::Database, input: MyInput) -> MyTracked<'db> {
|
2022-09-13 00:18:19 +00:00
|
|
|
MyTracked::new(db, input.field(db) / 2)
|
|
|
|
}
|
|
|
|
|
2024-07-19 12:05:39 +00:00
|
|
|
fn main() {
|
|
|
|
let mut db = salsa::default_database();
|
2022-09-25 01:23:36 +00:00
|
|
|
let input = MyInput::new(&db, 22);
|
2022-09-13 00:18:19 +00:00
|
|
|
let tracked = tracked_fn(&db, input);
|
|
|
|
input.set_field(&mut db).to(24);
|
2024-07-19 12:05:39 +00:00
|
|
|
tracked.field(&db); // tracked comes from prior revision
|
2022-09-13 00:18:19 +00:00
|
|
|
}
|