Created
August 9, 2012 22:44
-
-
Save dbp/3308745 to your computer and use it in GitHub Desktop.
Rust Pretty printing closures
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// how pretty printer formats closures (I think; I'm unable to build from incoming right now to check) | |
fn main() { | |
do something |foo| | |
{ | |
something_long_enough_to_not; | |
fit_on_a_single_line; | |
} | |
let my_fn = || | |
{ | |
something_long_enough_to_not; | |
fit_on_a_single_line; | |
}; | |
} | |
// how they would be written by a person (in my opinion) | |
fn main() { | |
do something |foo| { | |
something_long_enough_to_not; | |
fit_on_a_single_line; | |
} | |
let my_fn = || { | |
something_long_enough_to_not; | |
fit_on_a_single_line; | |
}; | |
} | |
/* What this means: | |
* closures should not be wrapped inside a box of their own - the argument list | |
* and opening bracket should be part of the head, and the contents of the closure | |
* should be a block. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment