0
$ rustc --test mapAsMapKey.rs 
mapAsMapKey.rs:18:43: 18:52 error: mismatched types: expected `fn@(&&@map_a) -> uint` but found `extern fn(@map_a) -> uint` (expected argument mode ++ but found &&)
mapAsMapKey.rs:18     let b: map_b = hashmap::<@map_a, uint>(rmap_hash, rmap_eqer);
                                                             ^~~~~~~~~
mapAsMapKey.rs:18:54: 18:63 error: mismatched types: expected `fn@(&&@map_a, &&@map_a) -> bool` but found `extern fn(@map_a, @map_b) -> bool` (expected argument mode ++ but found &&)
mapAsMapKey.rs:18     let b: map_b = hashmap::<@map_a, uint>(rmap_hash, rmap_eqer);
                                                                        ^~~~~~~~~
error: aborting due to 2 previous errors

防锈功能:

fn rmap_hash (m: @map_a) -> uint { 0 }
fn rmap_eqer (m1: @map_a, m2: @map_b) -> bool { true }

线路触发:

let b: map_b = hashmap::<@map_a, uint>(rmap_hash, rmap_eqer);
4

1 回答 1

1

如果你像这样编写 Rust 函数,它会起作用吗?

fn rmap_hash (&&m: @map_a) -> uint { 0 }

fn rmap_eqer (&&m1: @map_a, &&m2: @map_b) -> bool { true }
于 2012-07-17T17:40:30.337 回答