diff --git a/src/consts.rs b/src/consts.rs index b6695416..5f437fbc 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -34,10 +34,9 @@ pub const FILE_TEMPLATE: &'static str = r#"%b"#; pub const EXPR_TEMPLATE: &'static str = r#" %p fn main() { - let __cargo_script_expr = { -{%b} - }; - println!("{:?}", __cargo_script_expr); + match ({%b}) { + __cargo_script_expr => println!("{:?}", __cargo_script_expr) + } } "#; diff --git a/tests/tests/expr.rs b/tests/tests/expr.rs index f8616b0f..b4eae64e 100644 --- a/tests/tests/expr.rs +++ b/tests/tests/expr.rs @@ -12,6 +12,12 @@ fn test_expr_dnc() { assert!(!out.success()); } +#[test] +fn test_expr_temporary() { + let out = cargo_script!("-e", "[1].iter().max()").unwrap(); + assert!(out.success()); +} + #[test] fn test_expr_dep() { let out = cargo_script!("-D", "boolinator=0.1.0",