Skip to content

Instantly share code, notes, and snippets.

@dbp
Created August 9, 2012 22:44
Show Gist options
  • Save dbp/3308745 to your computer and use it in GitHub Desktop.
Save dbp/3308745 to your computer and use it in GitHub Desktop.
Rust Pretty printing closures
// 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