不匹配的类型:`expect fn @(&& @type) - > uint`但找到`extern fn(@map_a) - > uint`(预期参数模式++但发现&&)

时间:2012-07-16 20:27:47

标签: types rust

$ 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);

1 个答案:

答案 0 :(得分:1)

如果您编写像这样的Rust函数吗?

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

fn rmap_eqer (&&m1: @map_a, &&m2: @map_b) -> bool { true }