2012-07-16 49 views
0
$ rustc --test mapAsMapKey.rs 
mapAsMapKey.rs:18:43: 18:52 error: mismatched types: expected `[email protected](&&@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 `[email protected](&&@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 @(@ &&型) - > uint`但發現`的extern FN(@map_a) - > uint`(預期參數模式++但發現&&)

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

請問,如果你寫這樣的防鏽功能,它的工作?

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

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

是。正如你在IRC上說。雖然我仍然不知道它們是什麼。 – Havvy 2012-07-18 06:38:11

相關問題