One long line is difficult to read, so it’s best to divide it. It’s often wise to introduce a newline and other whitespace to help break up long lines.
But I can't do that via rust-analyzer in VS Code.
Expect:
io::stdin()
.read_line(&mut guess)
.expect("Failed to read line");
After Save:
io::stdin().read_line(&mut guess).expect("Failed to read line");
I'm not sure whether this is a "good practice", but for isolated examples where it helps readability, I tend to put a comment to force the line to wrap:
io::stdin() //rustfmt hint
.read_line(&mut guess)
.expect("Failed to read line");
Sometimes an empty comment looks better, but for others sake I'll mention that it's there to nudge rustfmt.
This way, it will continue to wrap lines consistently even if other people edit the file with no changes to their rustfmt config
Ideally you should configure rustfmt per project and commit .rustfmt.toml in your repo. That way the style stays consistent in a project regardless of author. I would also suggest enforcing rustfmt as a CI check.