Skip to content

closures and block formatting very verbose #1449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nikomatsakis opened this issue Apr 13, 2017 · 1 comment · Fixed by #1572
Closed

closures and block formatting very verbose #1449

nikomatsakis opened this issue Apr 13, 2017 · 1 comment · Fixed by #1572

Comments

@nikomatsakis
Copy link

@ChristopherDavenport was helpfully applying rustfmt to rayon, using the rfc-rustfmt settings. The new fn signatures look great, but closures result in quite a lot of indentation:

#[test]
fn future_rayon_wait_1_thread() {
    // run with only 1 worker thread; this would deadlock if we couldn't make progress
    let mut result = None;
    ThreadPool::new(Configuration::new().num_threads(1))
        .unwrap()
        .install(
            || {
                scope(
                    |s| {
                        use std::sync::mpsc::channel;
                        let (tx, rx) = channel();
                        let a = s.spawn_future(lazy(move || Ok::<usize, ()>(rx.recv().unwrap())));
                        //                          ^^^^ FIXME: why is this needed?
                        let b = s.spawn_future(a.map(|v| v + 1));
                        let c = s.spawn_future(b.map(|v| v + 1));
                        s.spawn(move |_| tx.send(20).unwrap());
                        result = Some(c.rayon_wait().unwrap());
                    },
                );
            },
        );
    assert_eq!(result, Some(22));
}
@vorner
Copy link

vorner commented Apr 25, 2017

I think I see the same annoyance. I have code like this:

vec.into_iter()
    .map(|elemente| {
        do_stuff(element)
    })
    .collect();

And rustfmt tries to put newlines there, like this:

vec.into_iter()
    .map(
        |elemente| {
            do_stuff(element)
        }
    )
    .collect();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants