Modify Rustfmt to force empty line between function bodies

Generally I am very happy with the defauts of Rustfmt.

Only this is what I do not like:

I would like an empty line between function bodies:

impl Something {
    pub fn path(&self) -Option<&String{
        self.path.as_ref()
    }
    pub fn set_path(&mut self, path: &str) {
        self.path = Some(path.to_string());
    }
    pub fn set_path_option(&mut self, path_option: Option<String>) {
        self.path = path_option;
    }
}

I would like an empty line between function bodies:

impl Something {
    pub fn path(&self) -Option<&String{
        self.path.as_ref()
    }

    pub fn set_path(&mut self, path: &str) {
        self.path = Some(path.to_string());
    }

    pub fn set_path_option(&mut self, path_option: Option<String>) {
        self.path = path_option;
    }
}

I could not find any option for this (Rustfmt), as this should not apply to all braces and for functions this options does not seem available.

1 Like

It sounds like the option does not exist. You could file an issue for it on the github repository.

3 Likes

There's is already a discussion here: [unstable option] blank_lines_lower_bound · Issue #3382 · rust-lang/rustfmt · GitHub

5 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.