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 with include_str! #4

Open
DerpyCrabs opened this issue Feb 27, 2019 · 1 comment
Open

Using with include_str! #4

DerpyCrabs opened this issue Feb 27, 2019 · 1 comment

Comments

@DerpyCrabs
Copy link

I'm trying to include file using include_str! macro:
#[shell(cmd = "python -c")] fn run_python(name: &str) -> Result<String, Box<std::error::Error>> { include_str("main.py") }
but getting an error on compilation:
--> src/main.rs:3:1 | 3 | #[shell(cmd = "python -c")] help: message: Invalid input. Expected fn containing only string literal without any other statements
Is it possible to use include_str! macro for this or can I include file through other means?

@synek317
Copy link
Owner

Unfortunately, it is currently not possible:

    if let Some(Stmt::Expr(Expr::Lit(ExprLit {
        lit: Lit::Str(ref program),
        ..
    }))) = input.block.stmts.iter().next()

include_str! is a very good extension.

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