mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-08-04 19:08:32 +00:00
implement the Storage<DB> change
This commit is contained in:
parent
4bf46f5f24
commit
67687376ed
22 changed files with 152 additions and 254 deletions
|
@ -16,16 +16,8 @@ use crate::interner::InternerDatabase;
|
|||
#[salsa::database(InternerDatabase, CompilerDatabase)]
|
||||
#[derive(Default)]
|
||||
pub struct DatabaseImpl {
|
||||
runtime: salsa::Runtime<DatabaseImpl>,
|
||||
storage: salsa::Storage<DatabaseImpl>,
|
||||
}
|
||||
|
||||
/// This impl tells salsa where to find the salsa runtime.
|
||||
impl salsa::Database for DatabaseImpl {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime<Self> {
|
||||
&self.runtime
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<Self> {
|
||||
&mut self.runtime
|
||||
}
|
||||
}
|
||||
impl salsa::Database for DatabaseImpl {}
|
||||
|
|
|
@ -77,19 +77,10 @@ fn length(db: &impl HelloWorld, (): ()) -> usize {
|
|||
#[salsa::database(HelloWorldStorage)]
|
||||
#[derive(Default)]
|
||||
struct DatabaseStruct {
|
||||
runtime: salsa::Runtime<DatabaseStruct>,
|
||||
storage: salsa::Storage<Self>,
|
||||
}
|
||||
|
||||
// Tell salsa where to find the runtime in your context.
|
||||
impl salsa::Database for DatabaseStruct {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime<Self> {
|
||||
&self.runtime
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<Self> {
|
||||
&mut self.runtime
|
||||
}
|
||||
}
|
||||
impl salsa::Database for DatabaseStruct {}
|
||||
// ANCHOR_END:database
|
||||
|
||||
// This shows how to use a query.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue