Crates.io | rhack |
lib.rs | rhack |
version | 0.1.0 |
source | src |
created_at | 2021-03-28 02:45:02.724399 |
updated_at | 2021-03-28 02:45:02.724399 |
description | Temporary edits to your Rust dependencies |
homepage | https://github.com/nakabonne/rhack |
repository | https://github.com/nakabonne/rhack |
max_upload_size | |
id | 374513 |
size | 27,832 |
You want to quickly put a sneaky macro kind of like dbg!
into external crates to find out how some internal data structure works? If so rhack
is for you!
rhack
makes it easier to edit external crates code that your project depends on.
Let's say you want to modify the reqwest
crate.
[dependencies]
reqwest = "0.11"
Run the following:
$ rhack edit reqwest
This will make a copy of the crate into $HOME/.rhack/reqwest-0.11.1
and add its path to the [patch] section in your Cargo.toml whose path is automatically detected:
[patch.crates-io]
reqwest = { path = "/home/you/.rhack/reqwest-0.11.1" }
Now your package uses the locally checked out copy instead of one from crates.io. You can now open the files (typically by leveraging the "Jump to Definition" feature) and then feel free to modify the source code.
Simply run the undo
command then you can undo all of the changes to your Cargo.toml:
$ rhack undo
Keep in mind that this command doesn't remove any copy of crates.
It uses $HOME/.rhack
as the destination to copy the source code of the external crates by default. You can change it by setting and exposing the $RHACK_DIR
environment variable.
This tool is highly inspired by gohack. It clearly stimulated an incentive to creation. A big "thank you!" goes out to them.