如何克隆 Rust 库,更改它,然后在我自己的项目中使用它
我想克隆 tokio
库并对其进行一些更改,然后在另一个项目中使用它,就像我在我的项目中指定 tokio
作为依赖项一样Cargo.toml
。
我该怎么做呢?
I want to clone the tokio
library and make a few changes to it, then use it in another project, just like I would if I had specified tokio
as a dependency in my Cargo.toml
.
How would I go about doing that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 路径依赖这。路径被解释为相对于它们出现的
Cargo.toml
,因此您有几个选择:将您的 tokio 分支作为项目中的子目录
tokio
,或在那里进行符号链接:让您的 tokio fork 位于您的主目录中的其他位置:
或者其他对您最有意义的位置。
You could use a path dependency for this. Paths are interpreted as relative to the
Cargo.toml
they appear in, so you have a few options:Have your tokio fork as a subdirectory
tokio
in your project, or symlinked there:Have your tokio fork live somewhere else in your home directory:
Or wherever else makes the most sense for you.
作为替代方案,如果您想使用 git 而不是本地开发,您可以分叉存储库并使用引用它:
看看 有关如何指定依赖项的文档
As an alternative, if instead of local dev, you want to use git, you could fork the repo an use reference it:
Take a look at the documentation on how to specify dependencies