如何克隆 Rust 库,更改它,然后在我自己的项目中使用它

发布于 2025-01-11 15:30:55 字数 132 浏览 3 评论 0原文

我想克隆 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

愁杀 2025-01-18 15:30:55

您可以使用 路径依赖这。路径被解释为相对于它们出现的 Cargo.toml ,因此您有几个选择:

将您的 tokio 分支作为项目中的子目录 tokio ,或在那里进行符号链接:

[dependencies]
tokio = { path = "tokio" }

让您的 tokio fork 位于您的主目录中的其他位置:

[dependencies]
tokio = { path = "/home/youruser/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:

[dependencies]
tokio = { path = "tokio" }

Have your tokio fork live somewhere else in your home directory:

[dependencies]
tokio = { path = "/home/youruser/tokio-fork" }

Or wherever else makes the most sense for you.

一个人的旅程 2025-01-18 15:30:55

作为替代方案,如果您想使用 git 而不是本地开发,您可以分叉存储库并使用引用它:

tokio = { git = "https://github.com/your-user/tokio" }

看看 有关如何指定依赖项的文档

As an alternative, if instead of local dev, you want to use git, you could fork the repo an use reference it:

tokio = { git = "https://github.com/your-user/tokio" }

Take a look at the documentation on how to specify dependencies

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文