Description
In issues #3206 #3416 #3135, wrap_str
is preventing some possibly good formatting because of long strings. The return type being an Option
, the fact that the rewrite failed because of a long string is lost.
If that were returning a Return
, then the failure reason could be passed up for the callee to handle as appropriate.
For example, it seems the rewrite in #3416 could allow the line to overflow (which anyway would be caught by the LineOverflow
logic). However, there are cases where a better formatting is possible, e.g.:
// original
fn foo() {
let suuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuum = xxxxxxx
.map(|x| x + 5)
.map(|x| x / 2)
.fold(0, |acc, x| acc + x);
}
// formatted
fn foo() {
let suuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuum =
xxxxxxx.map(|x| x + 5)
.map(|x| x / 2)
.fold(0, |acc, x| acc + x);
}
Although in that example there is no long string, the current wrap_str
logic makes that formatting possible.
With a Return
as the return type, rewrite methods could be made more flexible to various kinds of errors.
However, that change would require some heavy refactoring I think.
What do you think about such a change ?