aboutsummaryrefslogtreecommitdiff
path: root/examples/learn/15-generics.zc
blob: 2da24e506bacd71bf6ed39aa426bbb8d1f0ae42e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
namespace;
include rt;
struct record<K, V> { K key; V val; };
struct point { int x; int y; };
K keyof<K, V>(record<K, V>* r) { return r.key; }
fn main() {
	record<int, point>* r = rt.new(record<int, point>);
	r.key = 9;
	rt.put_n(keyof(r)); rt.put_c(10);
}