shellfn icon indicating copy to clipboard operation
shellfn copied to clipboard

Using with include_str!

Open DerpyCrabs opened this issue 6 years ago • 1 comments

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?

DerpyCrabs avatar Feb 27 '19 18:02 DerpyCrabs

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.

synek317 avatar Feb 28 '19 06:02 synek317