2 // Test associated types appearing in tuple-like enum variants.
9 fn to_index(&self) -> usize;
12 pub enum VarValue<K:UnifyKey> {
14 Root(K::Value, usize),
17 fn get<'a,K:UnifyKey<Value=Option<V>>,V>(table: &'a Vec<VarValue<K>>, key: &K) -> &'a Option<V> {
18 match table[key.to_index()] {
19 VarValue::Redirect(ref k) => get(table, k),
20 VarValue::Root(ref v, _) => v,
24 impl UnifyKey for usize {
25 type Value = Option<char>;
26 fn to_index(&self) -> usize { *self }
30 let table = vec![/* 0 */ Redirect(1),
32 /* 2 */ Root(Some('x'), 0),
34 assert_eq!(get(&table, &0), &Some('x'));