Add suggestion for explicit_write lint#3450
Conversation
phansch
left a comment
There was a problem hiding this comment.
need to fix one leftover debug variable name
7fe226f to
13819ce
Compare
| }; | ||
|
|
||
| // We need to remove the last trailing newline from the string because the | ||
| // underlying `fmt::write` function doesn't know wether `println!` or `print!` was |
| // used. | ||
| let mut write_output: String = write_output.to_string(); | ||
| if write_output.ends_with('\n') { | ||
| write_output.truncate(write_output.len() - 1) |
There was a problem hiding this comment.
How about write_output.pop()?
| // We need to remove the last trailing newline from the string because the | ||
| // underlying `fmt::write` function doesn't know wether `println!` or `print!` was | ||
| // used. | ||
| let mut write_output: String = write_output_string(write_args).unwrap(); |
There was a problem hiding this comment.
I'm not sure if this function can fail on some inputs, but if there are cases where this fails, it should probably fall back to not using a suggestion. Otherwise, maybe expect() would be better?
b3d41bf to
c84a17d
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
* Fix typo * Handle None value instead of using `unwrap()` * `pop()` instead of `x.truncate(x.len() - 1)`
0933b7a to
194acaf
Compare
flip1995
left a comment
There was a problem hiding this comment.
travis is currently failing (https://travis-ci.org/rust-lang/rust-clippy/jobs/467013498#L152). I'm working on a fix. If travis is working again r=me.
|
@bors rollup |
|
Let's queue this @bors r+ |
|
📌 Commit 194acaf has been approved by |
…lip1995 Add suggestion for explicit_write lint Closes #2083
|
☀️ Test successful - status-appveyor, status-travis |
Closes #2083