weisbrja
weisbrja

Reputation: 315

How to clone rust library, change it and then use it in my own project

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?

Upvotes: 2

Views: 1263

Answers (2)

Netwave
Netwave

Reputation: 42688

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

Upvotes: 3

cdhowie
cdhowie

Reputation: 169008

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.

Upvotes: 6

Related Questions