Skip to content
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

How to keep the comments at the same line when reformatting the code with Rust code formatter? #5856

Closed
q2333gh opened this issue Jul 22, 2023 · 1 comment

Comments

@q2333gh
Copy link

q2333gh commented Jul 22, 2023

I use rust-analyzer in VSCode.
with all default settings.
Check out the gif: when press reformat-hot-key:
my comments move away from the same line of code,
which is really not good-looking.
if the comments is at the same line of code ,
reading the codes will be much more fluent.
Making the comments become optional read.

The code I wish when reformat.

fn main() {
    let guess: u32 = match guess.trim().parse() {// :u32 : type casting, work with .parse()
        Ok(num) => num,
        Err(_) => { //_  means any error
            println!("Please input numbers!");
            continue;
        }
    };
}

The code I don`t like when reformat:

fn main() {
    let guess: u32 = match guess.trim().parse() {
        // :u32 : type casting, work with .parse()
        Ok(num) => num,
        Err(_) => {
            //_  means any error
            println!("Please input numbers!");
            continue;
        }
    };
}

enter image description here

I want to get some help with it,
and I assume maybe some people also need this formatting behaviour.

@calebcartwright
Copy link
Member

Thanks but closing as a duplicate of #3255

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

No branches or pull requests

2 participants