mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-15 01:39:25 +00:00
31 lines
No EOL
574 B
Rust
31 lines
No EOL
574 B
Rust
|
|
#[salsa::jar(db = Db)]
|
|
struct Jar(MyInput);
|
|
|
|
trait Db: salsa::DbWithJar<Jar> {}
|
|
|
|
#[salsa::input(jar = Jar)]
|
|
struct MyInput {
|
|
field: u32,
|
|
#[id]
|
|
id_one: u32,
|
|
}
|
|
|
|
#[salsa::db(Jar)]
|
|
#[derive(Default)]
|
|
struct Database {
|
|
storage: salsa::Storage<Self>,
|
|
}
|
|
|
|
impl salsa::Database for Database {}
|
|
|
|
impl Db for Database {}
|
|
|
|
|
|
fn main() {
|
|
let mut db = Database::default();
|
|
let input = MyInput::new(&mut db, 3, 4);
|
|
// should not compile as `id_one` should not have a setter
|
|
// compile error: method `set_id_one` not found in scope
|
|
input.set_id_one(1);
|
|
} |