Skip to content
On this page

函数1:exercises/functions/functions1.rs

题目

rust
// functions1.rs
//
// Execute `rustlings hint functions1` or use the `hint` watch subcommand for a
// hint.

// I AM NOT DONE

fn main() {
    call_me();
}

题目解析

编译器报错信息如下:

txt
⚠️  Compiling of exercises/functions/functions1.rs failed! Please try again. Here's the output:
error[E0425]: cannot find function `call_me` in this scope
 --> exercises/functions/functions1.rs:9:5
  |
9 |     call_me();
  |     ^^^^^^^ not found in this scope

error: aborting due to previous error

For more information about this error, try `rustc --explain E0425`.

报错提示我们,函数call_me在当前作用域不存在。

根据调用的形式call_me(),我们知道这个函数不接受任何参数,并且没有返回值。所以我们添加以下这个函数的代码:

rust
fn main() {
    call_me();
}

fn call_me() {} 

参考资料

Powered by VitePress