convert the example into a test

This commit is contained in:
Niko Matsakis 2018-09-28 13:54:40 -04:00
parent abb4345c08
commit 086005dc52
2 changed files with 11 additions and 1 deletions

View file

@ -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() {

View file

@ -48,7 +48,7 @@ pub trait BaseQueryContext: Sized {
pub trait Query<QC: BaseQueryContext>: Debug + Default + Sized + 'static {
type Key: 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;
}