cargo-play icon indicating copy to clipboard operation
cargo-play copied to clipboard

Using local modules

Open viniciusd opened this issue 5 years ago • 1 comments

First of all, congrats for the awesome work you've put in here!

I've got the following files:

src
├── foo.rs
├── lib.rs
├── main.rs

I am trying to use some content from my lib, but the imports won't resolve even if I use cargo play src/main.rs src/lib.rs src/foo.rs

How can I use my own library?

viniciusd avatar Nov 24 '19 17:11 viniciusd

One hack you can do is to specify the dependency with its path. For example, I have a Rust library at ~/playground/testlib. I can write the following to use code in that library:

//# testlib = { path = "/Users/fanzeyi/playground/testlib" }

use testlib::foobar;

fn main() {
    println!("test");
    foobar();
}

This is a little tedious. Let me see if I can make it so cargo-play can convert relative path to absolute path.

fanzeyi avatar Jun 15 '20 04:06 fanzeyi