Skip to content

Alignment of let bindings #3821

Open
Open
@wdanilo

Description

@wdanilo

Hi!
I really like what rustfmt is doing, however, one thing hurts me strongly here. It allows the vertical alignment of struct fields, but does not allow for such alignment of let bindings. Consider the following code:

impl Scene {
    fn new() -> Result<Scene, Error> {
        let doc = document()?;
        let canvas = doc.get_element_by_id("canvas").ok_or(DOMError::missing("canvas"))?;
        let data = Rc::new(SceneData { canvas, context });
        let data_weak = Rc::downgrade(&data);
        ....
    }
}

I believe it is much nicer to read the following code:

impl Scene {
    fn new() -> Result<Scene, Error> {
        let doc       = document()?;
        let canvas    = doc.get_element_by_id("canvas").ok_or(DOMError::missing("canvas"))?;
        let data      = Rc::new(SceneData { canvas, context });
        let data_weak = Rc::downgrade(&data);
        ....
    }
}

Would it be possible to add some treshold option to rustfmt for such a style? :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    community drivenIssues the rustfmt team will not work on directly. Intended for contributors!feature-requestp-low

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions