gpt4 book ai didi

types - 类型不匹配。预期 i32,发现 ()

转载 作者:行者123 更新时间:2023-11-29 07:49:56 26 4
gpt4 key购买 nike

<分区>

这段代码:

fn ackermann(m: i32, n: i32) -> i32 {
if m == 0 {
return n + 1;
} else if m > 0 && n == 0 {
return ackermann(m - 1, 1);
} else if m > 0 && n > 0 {
return ackermann(m - 1, ackermann(m, n - 1));
}
}

编译时出现错误:

error: mismatched types [--explain E0308]
--> src/main.rs:3:5
|>
3 |> if m == 0 {
|> ^ expected i32, found ()
note: expected type `i32`
note: found type `()`

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