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

Importing files with "mod" does not work #70

Closed
x3pi opened this issue Nov 21, 2019 · 1 comment
Closed

Importing files with "mod" does not work #70

x3pi opened this issue Nov 21, 2019 · 1 comment

Comments

@x3pi
Copy link

x3pi commented Nov 21, 2019

mod hello;
    ^^^^^ 
file not found for module 'hello'

I used the "mod" keyword to import files, but it didn't work. How to solve this problem.

@davidlattimore
Copy link
Collaborator

Interesting. I'd not thought of trying that. It'd be a bit tricky to make it work, since the code you write gets written to a file in a temporary directory, so it can't easily reference the code in the directory in which you ran evcxr. You can pull in your code as a crate though. For example:
:dep hello = { path = "." }

Replace "hello" with whatever the name your crate is. When it does this, evcxr interprets the path as relative to where you launched evcxr and rewrites it as an absolute path.

You'll only be able to reference pub items.

Adding support for mod is an interesting idea. I'm somewhat unsure of how it would work though. Especially if the loaded mod depended on stuff from the root of the crate in which it was defined. I'd have to give that some thought.

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