summary refs log tree commit diff
path: root/src/test/run-pass/explicit-self-generic.rs
blob: ec032506403b47a490d385d5dbf668f1ff5f7687 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
extern mod std;

/**
 * A function that returns a hash of a value
 *
 * The hash should concentrate entropy in the lower bits.
 */
type HashFn<K> = pure fn~(K) -> uint;
type EqFn<K> = pure fn~(K, K) -> bool;

enum LinearMap<K,V> {
    LinearMap_({
        resize_at: uint,
        size: uint})
}

fn linear_map<K,V>() -> LinearMap<K,V> {
    LinearMap_({
        resize_at: 32,
        size: 0})
}

impl<K,V> LinearMap<K,V> {
    fn len(&mut self) -> uint {
        self.size
    }
}

fn main() {
    let mut m = ~linear_map::<(),()>();
    assert m.len() == 0;
}