From 086005dc52dd235b6a983c70cebafdc1d92fa953 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Fri, 28 Sep 2018 13:54:40 -0400 Subject: [PATCH] convert the example into a test --- examples/hello_world/main.rs | 10 ++++++++++ src/lib.rs | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/examples/hello_world/main.rs b/examples/hello_world/main.rs index 3e74c0e..5fbf33f 100644 --- a/examples/hello_world/main.rs +++ b/examples/hello_world/main.rs @@ -5,6 +5,16 @@ mod implementation; use self::class_table::ClassTableQueryContext; 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() { let query = QueryContextImpl::default(); for f in query.all_fields().of(()).iter() { diff --git a/src/lib.rs b/src/lib.rs index d5f4ae5..7871c7d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -48,7 +48,7 @@ pub trait BaseQueryContext: Sized { pub trait Query: Debug + Default + Sized + 'static { type Key: Clone + Debug + Hash + Eq + Send; type Value: Clone + Debug + Hash + Eq + Send; - type Storage: QueryStorageOps; + type Storage: QueryStorageOps + Send; fn execute(query: &QC, key: Self::Key) -> Self::Value; }