Closed insomnimus closed 3 years ago
Thanks for bringing this to our attention!!
The problem boils down to the following
The generated code is this:
fn main(){ println!("{:?}",{ 2 + 2 // returns 4 }); }
By adding the \n
after the end of the user provided expression it transforms the expression posted to play.rlo into:
fn main(){ println!("{:?}",{ 2 + 2 // returns 4
}); }
effectively moving the remaining closing braces to the next line, preventing them from being commented out.
Instead of just breaking up the end, could we break up the whole expression into separate lines?
fn main(){
println!("{:?}",{
2 + 2 // returns 4
}); }
@tinaun Do you have any thoughts about this?
The difference between a single new line and "more" formatting is how it looks in the Gist, should we share one with the user. So, it's inconsequential, atm.
If a code passed to
?eval
contains trailing single-line comments, the matching}
in the code is commented out.For example:
Will not work as expected.
I've added a single newline(
\n
) inplayground.rs
Where the expression is wrapped in a block to print out so the}
is not commented out.