mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-02-05 11:25:15 +00:00
convert the example into a test
This commit is contained in:
parent
abb4345c08
commit
086005dc52
2 changed files with 11 additions and 1 deletions
|
@ -5,6 +5,16 @@ mod implementation;
|
||||||
use self::class_table::ClassTableQueryContext;
|
use self::class_table::ClassTableQueryContext;
|
||||||
use self::implementation::QueryContextImpl;
|
use self::implementation::QueryContextImpl;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test() {
|
||||||
|
let query = QueryContextImpl::default();
|
||||||
|
let all_def_ids = query.all_fields().of(());
|
||||||
|
assert_eq!(
|
||||||
|
format!("{:?}", all_def_ids),
|
||||||
|
"[DefId(1), DefId(2), DefId(11), DefId(12)]"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let query = QueryContextImpl::default();
|
let query = QueryContextImpl::default();
|
||||||
for f in query.all_fields().of(()).iter() {
|
for f in query.all_fields().of(()).iter() {
|
||||||
|
|
|
@ -48,7 +48,7 @@ pub trait BaseQueryContext: Sized {
|
||||||
pub trait Query<QC: BaseQueryContext>: Debug + Default + Sized + 'static {
|
pub trait Query<QC: BaseQueryContext>: Debug + Default + Sized + 'static {
|
||||||
type Key: Clone + Debug + Hash + Eq + Send;
|
type Key: Clone + Debug + Hash + Eq + Send;
|
||||||
type Value: Clone + Debug + Hash + Eq + Send;
|
type Value: Clone + Debug + Hash + Eq + Send;
|
||||||
type Storage: QueryStorageOps<QC, Self>;
|
type Storage: QueryStorageOps<QC, Self> + Send;
|
||||||
|
|
||||||
fn execute(query: &QC, key: Self::Key) -> Self::Value;
|
fn execute(query: &QC, key: Self::Key) -> Self::Value;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue