This commit is contained in:
Niko Matsakis 2024-07-16 06:05:20 -04:00
parent 8a39bf029b
commit a0bdff5af7
2 changed files with 12 additions and 16 deletions

View file

@ -7,17 +7,10 @@ mod common;
use common::{HasLogger, Logger};
use expect_test::expect;
use salsa::Setter;
#[salsa::jar(db = Db)]
struct Jar(
MyInput,
MyTracked<'_>,
final_result_depends_on_x,
final_result_depends_on_y,
intermediate_result,
);
trait Db: salsa::DbWithJar<Jar> + HasLogger {}
#[salsa::db]
trait Db: salsa::Database + HasLogger {}
#[salsa::input]
struct MyInput {
@ -47,15 +40,17 @@ fn intermediate_result<'db>(db: &'db dyn Db, input: MyInput) -> MyTracked<'db> {
MyTracked::new(db, (input.field(db) + 1) / 2, input.field(db) / 2)
}
#[salsa::db(Jar)]
#[salsa::db]
#[derive(Default)]
struct Database {
storage: salsa::Storage<Self>,
logger: Logger,
}
#[salsa::db]
impl salsa::Database for Database {}
#[salsa::db]
impl Db for Database {}
impl HasLogger for Database {

View file

@ -7,11 +7,10 @@ mod common;
use common::{HasLogger, Logger};
use expect_test::expect;
use salsa::Setter;
#[salsa::jar(db = Db)]
struct Jar(MyInput, result_depends_on_x, result_depends_on_y);
trait Db: salsa::DbWithJar<Jar> + HasLogger {}
#[salsa::db]
trait Db: salsa::Database + HasLogger {}
#[salsa::input]
struct MyInput {
@ -31,15 +30,17 @@ fn result_depends_on_y(db: &dyn Db, input: MyInput) -> u32 {
input.y(db) - 1
}
#[salsa::db(Jar)]
#[salsa::db]
#[derive(Default)]
struct Database {
storage: salsa::Storage<Self>,
logger: Logger,
}
#[salsa::db]
impl salsa::Database for Database {}
#[salsa::db]
impl Db for Database {}
impl HasLogger for Database {