我正在尝试制作一个简单的程序来检查同一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" }
有关详细信息,请参见Specifying Dependencies文档中的Cargo.toml中的重命名依赖项部分。
关于rust - 在toml中导入带有别名的rust包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66289830/