rust - 在 toml 中导入带有别名的 rust 包
问题描述
我正在尝试制作一个简单的程序来检查同一个 rust 项目的两个不同分支的执行时间。
我想让我的 .toml 看起来像这样
[dependencies]
cron_original = { git = "https://github.com/zslayton/cron" }
cron_fork = { git = "https://github.com/koenichiwa/cron", branch = "feature/reimplement-queries"}
我的程序看起来像这样:
fn main() {
let expression = String::from("0-59 * 0-23 ?/2 1,2-4 ? *");
let schedule_orig = cron_original::Schedule::from_str(expression);
let schedule_fork = cron_fork::Schedule::from_str(expression);
// Check difference in execution times on these structs
}
但我得到了no matching package named 'cron_fork' found
。无论如何要导入具有特定别名的包吗?我正在考虑创建一些可以自动执行此类检查的东西。
解决方案
您需要package
为这些依赖项指定键,以便 cargo 知道您确实需要这些包,即使您指定了不同的名称:
[dependencies]
cron_original = { git = "https://github.com/zslayton/cron", package="cron" }
cron_fork = { git = "https://github.com/koenichiwa/cron", branch = "feature/reimplement-queries", package="cron" }
有关详细信息,请参阅指定依赖项文档中的重命名 Cargo.toml中的依赖项部分。
推荐阅读
- database - 尝试添加连接时未生成数据表
- python - 确定每个组内的大小在另一列中具有相同的值
- c++ - 如何使用 clang LibTooling 获取函数指针参数名称?
- reactjs - Redux,React 用于单页应用程序登录和注销
- node.js - TypeError:无法读取未定义的属性“setDate”
- node.js - 如何在 Express.js 应用程序中将猫鼬模型与正确的 MongoDB 集合相关联?
- android - Android为ImageViews制作10dp渐变边框
- php - 做array_sum的更简单的方法?
- amazon-web-services - 使用 rekognition 时 lambda 任务超时错误
- ssl - 客户端无法在端口 5223 上使用 SSL 连接 ejabberd