import - 同一目录中文件的模块错误未找到 Rust 文件
问题描述
Rust 无法通过声明找到本地文件。我在 src 中有以下文件结构:
| main.rs
| lib.rs
| test.rs
| prog.rs
| file.rs
在 main.rs 我有
extern crate cratename;
mod prog;
use cratename::file1::File1;
...
prog::function() // This works
...
#[cfg(test)]
mod test;
在 lib.rs 我有
pub mod file1;
在 test.rs 我有
extern crate cratename
use cratename::file1::File1;
mod prog;
#[test]
...
prog::function() // This does not work
...
我不断收到错误
error[E0583]: file not found for module `prog`
我尝试将声明放在 lib.rs 中,但没有奏效。我已经尝试了许多其他涉及此声明以及 main.rs 的排列,但没有一个起作用。如果有帮助,prog.rs 不包含结构,也不使用 mod 关键字,它只包含公共函数。这让我难倒了一段时间。谢谢您的帮助。
解决方案
推荐阅读
- javascript - 使用 ADALJS 引发 HTTP 403 的图形安全端点
- azure - 尝试将 Azure CDN 端点与自定义源(指向 Azure Function App 代理的源)连接时出现问题
- mysql - 带有游标的 MySQL 存储过程
- reporting-services - 如何为报表的 Visual Studio 预览查找报表执行日志
- python - 根据内容查找 Python 文件
- vba - 由于 Private Declare 语句的位置导致编译错误
- powershell - 长时间运行任务后无法移动文件
- angular - 在 mat-table 中使用组件
- xml - 使用 powershell 将具有多个值的元素添加到现有的 xml 文件
- java - 我无法使用网格窗格正确地将图像放到窗口中