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 starlark_module! requires wide-ranging imports #12

antifuchs opened this Issue Oct 14, 2018 · 2 comments


None yet
2 participants

antifuchs commented Oct 14, 2018

I just tried using starlark-rust for a rewrite/extension of an old side-project of mine, and I've got an experience report in progress: Using the starlark_module! macro requires somewhat unergonomic boilerplate code.

Instead of the following 2015 edition rust (for 2018 edition rust, you have to pull in the macros explicitly, which is a bit more unwieldy since you also have to import all the macros that the starlark_module block expands into):

extern crate starlark;
use starlark::values::Value;

// all of the below things are required to expand the macro correctly 
// (I kept adding them until rustc stopped screaming at me):
use starlark::environment::Environment;
use starlark::values::function;
use starlark::values::ValueResult;

    ohai =>
        hi(_a) {

I believe this could be avoided by making the macro expansion use the $crate variable (weirdly enough not documented in newer editions of the rust book) to canonize names exported by starlark-rust. I'm happy to draft up a PR, it would be a straightforward search&replace job.


This comment has been minimized.


damienmg commented Oct 14, 2018


This comment has been minimized.


antifuchs commented Oct 14, 2018

Ah, I'm pretty sure that should work - I think that variable has been in rust since 1.5. I'll try now (:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment