Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using local modules #15

Open
viniciusd opened this issue Nov 24, 2019 · 1 comment
Open

Using local modules #15

viniciusd opened this issue Nov 24, 2019 · 1 comment

Comments

@viniciusd
Copy link

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?

@fanzeyi
Copy link
Owner

fanzeyi commented Jun 15, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants