mirror of
https://github.com/salsa-rs/salsa.git
synced 2024-11-24 20:20:26 +00:00
24 lines
524 B
Rust
24 lines
524 B
Rust
use salsa::prelude::*;
|
|
|
|
#[salsa::input]
|
|
struct MyInput {
|
|
field: u32,
|
|
}
|
|
|
|
#[salsa::tracked]
|
|
struct MyTracked<'db> {
|
|
field: u32,
|
|
}
|
|
|
|
#[salsa::tracked]
|
|
fn tracked_fn<'db>(db: &'db dyn salsa::Database, input: MyInput) -> MyTracked<'db> {
|
|
MyTracked::new(db, input.field(db) / 2)
|
|
}
|
|
|
|
fn main() {
|
|
let mut db = salsa::default_database();
|
|
let input = MyInput::new(&db, 22);
|
|
let tracked = tracked_fn(&db, input);
|
|
input.set_field(&mut db).to(24);
|
|
tracked.field(&db); // tracked comes from prior revision
|
|
}
|