salsa/examples/storage_varieties/queries.rs

24 lines
535 B
Rust
Raw Normal View History

2018-09-29 08:50:08 +00:00
crate trait CounterContext: salsa::BaseQueryContext {
fn increment(&self) -> usize;
}
crate trait QueryContext: CounterContext {
salsa::query_prototype! {
fn memoized() for Memoized;
fn transparent() for Transparent;
}
}
salsa::query_definition! {
crate Memoized(query: &impl QueryContext, (): ()) -> usize {
query.increment()
}
}
salsa::query_definition! {
#[storage(transparent)]
crate Transparent(query: &impl QueryContext, (): ()) -> usize {
query.increment()
}
}