gpt4 book ai didi

types - 不匹配的类型 : `expected fn@(&&@type) -> uint` but found `extern fn(@map_a) -> uint` (expected argument mode++ but found &&)

转载 作者:行者123 更新时间:2023-11-29 08:30:34 29 4
gpt4 key购买 nike

$ 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

使用rust 函数:

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

最佳答案

如果你这样写 Rust 函数,它能工作吗?

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

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

关于types - 不匹配的类型 : `expected fn@(&&@type) -> uint` but found `extern fn(@map_a) -> uint` (expected argument mode++ but found &&),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11512007/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com