Skip to content

Conversation

bluss
Copy link
Contributor

@bluss bluss commented Nov 27, 2016

For cargo script -e, simply pass the block to println. This allows
printing more expressions (those that borrow from temporaries that go
out of scope at the end of the statement).

For example, this makes cargo script -e '[1, 2, 3].iter().max()' compile.

for cargo script -e, simply pass the block to println. This allows
printing more expressions (those that borrow from temporaries that go
out of scope at the end of the statement).

For example, this makes cargo script -e '[1, 2, 3].iter().max()' compile.
@bluss
Copy link
Contributor Author

bluss commented Nov 27, 2016

I don't understand the testing setup to be honest. Trying to use '[1, 2, 3].iter().max()' in the test has an interesting failure.

@durka
Copy link
Contributor

durka commented Mar 14, 2017

So, I pulled it out of the println in #17 (which is exactly the inverse of this PR) to work around a bug in Rust. I think the bug has been fixed though.

@bluss
Copy link
Contributor Author

bluss commented Mar 14, 2017

We can write something more convoluted that preserves that:

match <expr> {
    x => println!("{:?}", x);
}

@bluss
Copy link
Contributor Author

bluss commented Mar 14, 2017

Updated using a match, it should satisfy both the concerns. This places the expression to be evaluated outside of the macro.

@DanielKeep
Copy link
Owner

Rebased and merged in 850fae4.

I have this nagging feeling there was a reason I put the value of the expression into a temporary, but I can't remember what it is, and this passes tests. So it can't have been that important.

@DanielKeep DanielKeep closed this Apr 10, 2017
@bluss
Copy link
Contributor Author

bluss commented Apr 10, 2017

Yay!

@bluss bluss deleted the script-temporaries branch July 27, 2017 08:24
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

Successfully merging this pull request may close these issues.

3 participants