-
Notifications
You must be signed in to change notification settings - Fork 72
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
vstd: map_err spec #1152
base: main
Are you sure you want to change the base?
vstd: map_err spec #1152
Conversation
The fmt check is failing with the following suggestion:
which I assume/hope is not actually the desired formatting? |
Ah, errrrr, you seem to have hit a particularly unfortunate case for the verusfmt due to the original line being just barely above the width (i.e., number of columns) limit, and there being lots of tiny one/two character pieces in it to play with wrt splitting the line up, so the constraints are kinda just rough. In particular, If you don't find it too terrible to shorten some identifiers, you could consider shortening the pub fn map_err<T, E, F, O: FnOnce(E) -> F>(res: Result<T, E>, op: O) -> (mapped_res: Result<T,F>) which goes below the width limit (is 97 characters), and thus isn't in the particularly awkward state. A more brute-force approach is to just add a If you are curious about or want to play around with improving the formatter to convince it into breaking at the Sorry that you've hit this nasty edge case for the formatter, but hopefully the above explanation gives some workarounds or at least explanations as to why it is behaving non-ideally. |
I took a look but I don't really grok the way pretty makes its decisions. I tried putting |
Wadler's original paper suggests this as a heuristic for deciding which of two possible lines is "prettier":
The
That makes sense -- in general with In Hayley's example, I think the printer has the option to break up the initial list of generic types ( Note that Rust doesn't allow a line break between the closing parenthesis of the arguments and the arrow ( |
I have no issue shortening |
I don't think there is an easy fix to |
It sounds like an easy fix would be to allow a newline before the |
Specifically I think we should allow newlines in all these places:
while making |
This PR adds a specification for the
Result
type'smap_err
method.