开发者社区> 问答> 正文

Rust 1.1版本--test编译报错?报错

fizzbuzz.rs内容如下:

fn div_by_three(num: int) -> bool {
   true
}

#[test]
fn test_div_by_three() {
    if div_by_three(1) {
        fail!("One is not three");
    }
}

保存后执行如下命令:

D:\rust>rustc --test fizzbuzz.rs
fizzbuzz.rs:8:5: 8:9 error: macro undefined: 'fail!'
fizzbuzz.rs:8     fail!("One is not three");
                  ^~~~
error: aborting due to previous error



新手,按照 http://www.rustforrubyists.com/book/book.html 的案例做的,提示fail这个关键字未定义,求解释。。

Rust版本1.1,windows的。

展开
收起
爱吃鱼的程序员 2020-06-14 15:32:31 595 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    写的不是很明白么。少模块<divclass='ref'>

    引用来自“orangleliu”的评论

    写的不是很明白么。少模块<divclass='ref'>

    引用来自“orangleliu”的评论

    写的不是很明白么。少模块你没有吧fall!这个函数所在的模块用use引用进来<divclass='ref'>

    引用来自“yangxingpping”的评论

    你没有吧fall!这个函数所在的模块用use引用进来

    2020-06-14 15:32:49
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载